nRF Connect SDK Bare Metal API 2.0.99
Loading...
Searching...
No Matches
ble_bas_client.h
1/*
2 * Copyright (c) 2012 - 2026 Nordic Semiconductor ASA
3 *
4 * SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
5 */
14#ifndef BLE_BAS_CLIENT_H__
15#define BLE_BAS_CLIENT_H__
16
17#include <stdint.h>
18#include <ble.h>
19#include <bm/bluetooth/ble_db_discovery.h>
20#include <bm/bluetooth/ble_gq.h>
21#include <bm/softdevice_handler/nrf_sdh_ble.h>
22
23#ifdef __cplusplus
24extern "C" {
25#endif
26
32#define BLE_BAS_CLIENT_DEF(_name) \
33 static struct ble_bas_client _name; \
34 NRF_SDH_BLE_OBSERVER(_name##_obs, ble_bas_client_on_ble_evt, &_name, HIGH)
35
59
67 uint16_t bl_handle;
68};
69
77 uint16_t conn_handle;
78 union {
80 struct {
87 struct {
89 uint8_t level;
92 struct {
94 uint32_t reason;
96 };
97};
98
100struct ble_bas_client;
101
108typedef void (*ble_bas_client_evt_handler_t)(struct ble_bas_client *bas_client,
109 const struct ble_bas_client_evt *evt);
110
126
140
156uint32_t ble_bas_client_init(struct ble_bas_client *bas_client,
157 const struct ble_bas_client_config *bas_client_config);
158
172void ble_bas_client_on_ble_evt(const ble_evt_t *ble_evt, void *ble_bas_client);
173
189
205
218uint32_t ble_bas_client_bl_read(struct ble_bas_client *bas_client);
219
234 const struct ble_db_discovery_evt *evt);
235
255uint32_t ble_bas_client_handles_assign(struct ble_bas_client *bas_client, uint16_t conn_handle,
256 const struct ble_bas_client_handles *peer_handles);
257
258#ifdef __cplusplus
259}
260#endif
261
262#endif /* BLE_BAS_CLIENT_H__ */
263
void ble_bas_client_on_ble_evt(const ble_evt_t *ble_evt, void *ble_bas_client)
Bluetooth LE event handler for the Battery Service Client.
uint32_t ble_bas_client_bl_notif_disable(struct ble_bas_client *bas_client)
Disable notifications on the Battery Level characteristic.
uint32_t ble_bas_client_bl_read(struct ble_bas_client *bas_client)
Read the Battery Level characteristic.
uint32_t ble_bas_client_handles_assign(struct ble_bas_client *bas_client, uint16_t conn_handle, const struct ble_bas_client_handles *peer_handles)
Assign client handles to the BAS Client instance.
void ble_bas_on_db_disc_evt(struct ble_bas_client *bas_client, const struct ble_db_discovery_evt *evt)
Handle events from the Database Discovery module.
ble_bas_client_evt_type
Battery Service Client event type.
Definition ble_bas_client.h:39
@ BLE_BAS_CLIENT_EVT_DISCOVERY_COMPLETE
Event indicating that the Battery Service was discovered at the peer.
Definition ble_bas_client.h:43
@ BLE_BAS_CLIENT_EVT_BATT_NOTIFICATION
Event indicating that a notification of the Battery Level characteristic was received from the peer.
Definition ble_bas_client.h:48
@ BLE_BAS_CLIENT_EVT_ERROR
Error event.
Definition ble_bas_client.h:57
@ BLE_BAS_CLIENT_EVT_BATT_READ_RESP
Event indicating that a read response on Battery Level characteristic was received from the peer.
Definition ble_bas_client.h:53
uint32_t ble_bas_client_bl_notif_enable(struct ble_bas_client *bas_client)
Enable notifications on the Battery Level characteristic.
void(* ble_bas_client_evt_handler_t)(struct ble_bas_client *bas_client, const struct ble_bas_client_evt *evt)
Event handler type.
Definition ble_bas_client.h:108
uint32_t ble_bas_client_init(struct ble_bas_client *bas_client, const struct ble_bas_client_config *bas_client_config)
Initialize the Battery Service Client module.
struct ble_db_discovery * db_discovery
Definition ble_bas_client.h:138
const struct ble_gq * gatt_queue
Definition ble_bas_client.h:136
ble_bas_client_evt_handler_t evt_handler
Definition ble_bas_client.h:134
Battery Service Client initialization structure.
Definition ble_bas_client.h:130
uint8_t level
Definition ble_bas_client.h:89
struct ble_bas_client_evt::@50::@54 error
struct ble_bas_client_evt::@50::@53 battery
uint16_t conn_handle
Definition ble_bas_client.h:77
struct ble_bas_client_evt::@50::@52 discovery_complete
enum ble_bas_client_evt_type evt_type
Definition ble_bas_client.h:75
uint32_t reason
Definition ble_bas_client.h:94
struct ble_bas_client_handles handles
Definition ble_bas_client.h:82
Battery Service Client Event structure.
Definition ble_bas_client.h:73
uint16_t bl_cccd_handle
Definition ble_bas_client.h:65
uint16_t bl_handle
Definition ble_bas_client.h:67
Structure containing the handles related to the Battery Service found on the peer.
Definition ble_bas_client.h:63
struct ble_bas_client_handles peer_bas_handles
Definition ble_bas_client.h:118
uint16_t conn_handle
Definition ble_bas_client.h:116
const struct ble_gq * gatt_queue
Definition ble_bas_client.h:124
ble_bas_client_evt_handler_t evt_handler
Definition ble_bas_client.h:122
Battery Service Client structure.
Definition ble_bas_client.h:114
Bluetooth LE database discovery event.
Definition ble_db_discovery.h:61
uint16_t conn_handle
Connection handle on which the discovery is started.
Definition ble_db_discovery.h:172
Bluetooth LE database discovery.
Definition ble_db_discovery.h:122
Bluetooth LE GATT Queue.
Definition ble_gq.h:238