Functions | |
uint32_t | ble_bas_c_init (ble_bas_c_t *p_ble_bas_c, ble_bas_c_init_t *p_ble_bas_c_init) |
Function for initializing the Battery Service Client module. More... | |
void | ble_bas_c_on_ble_evt (ble_evt_t const *p_ble_evt, void *p_context) |
Function for handling BLE events from the SoftDevice. More... | |
uint32_t | ble_bas_c_bl_notif_enable (ble_bas_c_t *p_ble_bas_c) |
Function for enabling notifications on the Battery Level characteristic. More... | |
uint32_t | ble_bas_c_bl_read (ble_bas_c_t *p_ble_bas_c) |
Function for reading the Battery Level characteristic. More... | |
void | ble_bas_on_db_disc_evt (ble_bas_c_t *p_ble_bas_c, ble_db_discovery_evt_t const *p_evt) |
Function for handling events from the Database Discovery module. More... | |
uint32_t | ble_bas_c_handles_assign (ble_bas_c_t *p_ble_bas_c, uint16_t conn_handle, ble_bas_c_db_t *p_peer_handles) |
Function for assigning handles to this instance of bas_c. More... | |
uint32_t ble_bas_c_bl_notif_enable | ( | ble_bas_c_t * | p_ble_bas_c | ) |
Function for enabling notifications on the Battery Level characteristic.
This function enables the notification of the Battery Level characteristic at the peer by writing to the CCCD of the Battery Level Characteristic.
p_ble_bas_c | Pointer to the Battery Service client structure. |
NRF_SUCCESS | If the SoftDevice has been requested to write to the CCCD of the peer. |
NRF_ERROR_NULL | Parameter is NULL. |
err_code | Otherwise, an error code returned by the SoftDevice API sd_ble_gattc_write. |
uint32_t ble_bas_c_bl_read | ( | ble_bas_c_t * | p_ble_bas_c | ) |
Function for reading the Battery Level characteristic.
p_ble_bas_c | Pointer to the Battery Service client structure. |
NRF_SUCCESS | If the read request was successfully queued to be sent to peer. |
uint32_t ble_bas_c_handles_assign | ( | ble_bas_c_t * | p_ble_bas_c, |
uint16_t | conn_handle, | ||
ble_bas_c_db_t * | p_peer_handles | ||
) |
Function for assigning handles to this instance of bas_c.
Call this function when a link has been established with a peer to associate the link to this instance of the module. This makes it possible to handle several links and associate each link to a particular instance of this module. The connection handle and attribute handles are provided from the discovery event BLE_BAS_C_EVT_DISCOVERY_COMPLETE.
[in] | p_ble_bas_c | Pointer to the Battery client structure instance for associating the link. |
[in] | conn_handle | Connection handle associated with the given Battery Client Instance. |
[in] | p_peer_handles | Attribute handles on the BAS server you want this BAS client to interact with. |
uint32_t ble_bas_c_init | ( | ble_bas_c_t * | p_ble_bas_c, |
ble_bas_c_init_t * | p_ble_bas_c_init | ||
) |
Function for initializing the Battery Service Client module.
This function initializes the module and sets up database discovery to discover the Battery Service. After calling this function, call ble_db_discovery_start to start discovery once a link with a peer has been established.
[out] | p_ble_bas_c | Pointer to the Battery Service Client structure. |
[in] | p_ble_bas_c_init | Pointer to the Battery Service initialization structure that contains the initialization information. |
NRF_SUCCESS | Operation success. |
NRF_ERROR_NULL | A parameter is NULL. |
err_code | Otherwise, an error code returned by ble_db_discovery_evt_register. |
void ble_bas_c_on_ble_evt | ( | ble_evt_t const * | p_ble_evt, |
void * | p_context | ||
) |
Function for handling BLE events from the SoftDevice.
This function handles the BLE events received from the SoftDevice. If a BLE event is relevant to the Battery Service Client module, the function uses the event's data to update interval variables and, if necessary, send events to the application.
[in] | p_ble_evt | Pointer to the BLE event. |
[in] | p_context | Pointer to the Battery Service client structure. |
void ble_bas_on_db_disc_evt | ( | ble_bas_c_t * | p_ble_bas_c, |
ble_db_discovery_evt_t const * | p_evt | ||
) |
Function for handling events from the Database Discovery module.
Call this function when you get a callback event from the Database Discovery module. This function handles an event from the Database Discovery module, and determines whether it relates to the discovery of Battery Service at the peer. If it does, this function calls the application's event handler to indicate that the Battery Service was discovered at the peer. The function also populates the event with service-related information before providing it to the application.
p_ble_bas_c | Pointer to the Battery Service client structure. | |
[in] | p_evt | Pointer to the event received from the Database Discovery module. |