I wrote some code that has multiple custom services where my device acts as GATT Server.
I register the handler for every service (3 in total) with NRF_SDH_BLE_OBSERVER as in this example:
#define BLE_CUS_DEF(_name) \
static ble_cus_t _name; \
NRF_SDH_BLE_OBSERVER(_name ## _obs, \
BLE_HRS_BLE_OBSERVER_PRIO, \
ble_cus_on_ble_evt, &_name)
The problem is that this will result in the SoftDevice calling all three EventHandler functions every time a service is used. Plus also calls some functions in the Peer manager. My problem is that they interfere with each other. So what would the best solution?
- Check in the EventHandler function for which service the request came for -> which value could I use for this? I tried to use for example the ServiceHandle but this is the same for all client or the Rx- and Tx-Handles but I have the same problem here.
- Write one huge callback function -> but then I run into the same problem as above where I need to distinguish the service
Thank you for any help!