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

BLE Custom Services - nRF52840 - SDK15.3

Hi,

   I want to implement a Single Base UUID with 3 Custom Characteristics. I followed the instructions which are mentioned in the https://github.com/maidenone/custom_ble_service_example - GitHub link to develop custom services. So I followed and implemented the custom services which is perfectly working. The example which is shared in the Github which having 1 - Base Custom UUID and 1 Custom Services with read and write operation. So now I added one more custom Services with read and write operation (1402 UUID). The newly added characteristics is visible in the Bluetooth terminal. So now how to access the interrupt handler to send the data and receive the data for the newly added custom characteristics independently?   Custom_BLE_Service.rar

I attached the code and screenshots

  • If you want to send (notify) data from the server ( often a peripheral) to the client (often a central), you use the call sd_ble_gatts_hvx(). Take a look at the example \examples\ble_peripheral\ble_app_blinky and the function ble_lbs_on_button_change() in \nRF5_SDK_15.3\components\ble\ble_services\ble_lbs\ble_lbs.c for guidance how to use this. In your case, the server is the nRF52840 device and the client is the phone (Bluetooth terminal)

    In order to receive the data (written from client to server), you have to create a BLE observer function through NRF_SDH_BLE_OBSERVER() and then look for the event BLE_GATTS_EVT_WRITE in the observer function. Take a look at the file \components\ble\ble_services\ble_lbs\ble_lbs.h, where ble_lbs_on_ble_evt() is added as a BLE observer, and at the file \components\ble\ble_services\ble_lbs\ble_lbs.c, where the function ble_lbs_on_ble_evt() is implemented. The received data is located in &p_ble_evt->evt.gatts_evt.params.write->data[0].

    Best regards,

    Simon

Related