nRF51 SDK: Functions

| nRF51 SDK

- Home
- Related Pages
- API Reference
- Data Structures

All Data Structures Functions Variables Typedefs Enumerations Enumerator Groups Pages
Functions
Functions
Battery Service Client

## 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_bas_c_t *p_ble_bas_c, const ble_evt_t *p_ble_evt)
| 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 requesting the peer to start sending notification of 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...

## Detailed Description

## Function Documentation

uint32_t ble_bas_c_bl_notif_enable | ( | ble_bas_c_t * | p_ble_bas_c | ) |

Function for requesting the peer to start sending notification of Battery Level characteristic.

This function will enable to notification of the Battery Level characteristic at the peer by writing to the CCCD of the Battery Level Characteristic.

Parameters

  p_ble_bas_c | Pointer to the Battery Service client structure.

Returns
  NRF_SUCCESS if the SoftDevice has been requested to write to the CCCD of the peer. Otherwise, an error code. This function propagates the 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.

Parameters

  p_ble_bas_c | Pointer to the Battery Service client structure.

Returns
  NRF_SUCCESS if the read request was successfully queued to be sent to peer. Otherwise an error code.

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 will register with the DB Discovery module. While doing so, it registers for the Battery Service. Doing so will make the DB Discovery module to look for the presence of a Battery Service instance at the peer when a discovery is started..

Parameters

  [in] | p_ble_bas_c | Pointer to the Battery Service client structure.
  [in] | p_ble_bas_c_init | Pointer to the Battery Service init structure containing the initialization information.

Returns
  NRF_SUCCESS on successful initialization. Otherwise an error code. This function propagates the error code returned by the Database Discovery module API ble_db_discovery_register.

void ble_bas_c_on_ble_evt | ( | ble_bas_c_t * | p_ble_bas_c,
|  | const ble_evt_t * | p_ble_evt
| ) |  |

Function for handling BLE events from the SoftDevice.

This function will handle the BLE events received from the SoftDevice. If the BLE event is relevant to the Battery Service Client module, then it uses it to update interval variables and, if necessary, send events to the application.

Parameters

  [in] | p_ble_bas_c | Pointer to the Battery Service client structure.
  [in] | p_ble_evt | Pointer to the BLE event.