I am trying to set up multiple ble diagnostic type services for different sensor devices, from a single nrf52840. The services share a common base id and some have the same characteristic uuids (eg. temp)
When doing a WRITE from a client (nRFConnect for example) on a characteristic, is there any information about the parent service included in the write event?
How can I determine what service the write was a part of?
Do I need separate base IDs for each service?
The write event will contain the UUID of the attribute written to but NOT the parent service UUID.
The usual way is that every service that expects its attributes to be written, saves the handles of those…
The usual way is that every service that expects its attributes to be written, saves the handles of those attributes when initialized and at every write event, they have a listener handler which compares the current write handle with the handle of the service the app is interested in. If both matches then it does some processing on it, else it ignores it.
ble_gatts_evt_write_t const * p_evt_write = &p_ble_evt->evt.gatts_evt.params.write;
if ( (p_evt_write->handle == my_service->handle) )
This way your service handling does not need to create each UUID->handle mapping in your application
Thanks, that works for me.