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

how to add default services like hrs,battery and temperature in our program

hi i am using nrf52840 s140 softdevice and 15.2 sdk.

can anyone tell how to add default services like hrs,battery and temperature in our own programs

Parents Reply Children
  • Taking a closer look at the BLE UART Emulation example will provide an answer to your question. If you take a closer look at the ble_advertising.h file (Advertising module), you can see that it includes an observer

    .
    .
    .
    NRF_SDH_BLE_OBSERVER(_name ## _ble_obs,                                                             \
                         BLE_ADV_BLE_OBSERVER_PRIO,                                                     \
                         ble_advertising_on_ble_evt, &_name); 
    .
    .
    .
    

    Every time a BLE event happens (for example BLE_GAP_EVT_DISCONNECTED), the function ble_advertising_on_ble_evt(..) is called. Inside that function there is a switch case that will handle a disconnect event, and start advertising again through on_disconnected(..)-->ble_advertising_start(..)

Related