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

Identifying the source of a callback defined with NRF_SDH_BLE_OBSERVER

I'm working with S132, SDK15.0 and an NRF52832 defining custom services. 

I have two services with each with several characteristics.  I need to be able to determine which service and/or characteristic a NRF_SDH_BLE_OBSERVER callback is related to.  eg. when I get BLE_GATTS_EVT_HVN_TX_COMPLETE I need to know which service and/or characteristic to pass the callback to.

I've studied the parameters in ble_evt_t but I don't see something that will help me here, none of the handles seem to change between services or characteristics.  The void* is of no help because it applies to the instance of NRF_SDH_BLE_OBSERVER not the instance of the service or characteristic.

Thanks,
Tom

Parents
  • Hi,

    I'm certainly no expert in this area, but at least in my application, the different services register their own observer and direct callbacks to their own handler. Doing this way would solve your problem I think.

    Regards

    Ola

  • Thanks but I don't think there is a way to define an observer for a particular service.  It's my observation that all observers are global and get called for all events.  There is no syntax I can see that would tie an observer to a particular service nor allow an observer to see which service (or characteristic) initiated the callback.

    Observer X always gets the void* parameter from the declaration of X but this only tells you which observer is being called, not which service is notifying.   You can use a different function for each observer to achieve the same affect.

Reply
  • Thanks but I don't think there is a way to define an observer for a particular service.  It's my observation that all observers are global and get called for all events.  There is no syntax I can see that would tie an observer to a particular service nor allow an observer to see which service (or characteristic) initiated the callback.

    Observer X always gets the void* parameter from the declaration of X but this only tells you which observer is being called, not which service is notifying.   You can use a different function for each observer to achieve the same affect.

Children
Related