This post is older than 2 years and might not be relevant anymore
More Info: Consider searching for newer posts

how can I read batt service and value of characteristic?

I connected by centrale to peripherial on NRF51 SDK9. Wich function can I observe value of my batt level?

Parents
  • Hi,

    I recommend adding the Battery Service Client module(ble_bas_c) to your central application. It's located in the folder SDK_folder\components\ble\ble_services\ble_bas_c. The ble_app_hrs_c example(SDK_folder\examples\ble_central\ble_app_hrs_c) in the SDK uses this module, so take a look at that example to see how to implement the module into your central application.

    The module will enable Battery Level Notification if the Batttery service is discovered at the peer, and you will receive the battery level on the BLE_BAS_C_EVT_BATT_NOTIFICATION event:

    case BLE_BAS_C_EVT_BATT_NOTIFICATION:
         printf("Battery = %d %%\r\n", p_bas_c_evt->params.battery_level);
    

    Take a look at the bas_c_evt_handler() function in main.c in the ble_app_hrs_c example.

Reply Children
No Data
Related