Hi,
So we have a project where we use the NUS, and we need to detect when a client subscribes. We eventually found a way, but it seems very obtuse and a bit black magic, so we wondered if this was the way things are "supposed" to work. Can you confirm?
First we register a handler on BLE events when we initialise the SD:
NRF_SDH_BLE_OBSERVER(m_ble_observer, APP_BLE_OBSERVER_PRIO, ble_evt_handler, NULL);Then in our handler we do this (actually a lot more but shortened for this post):
static void ble_evt_handler(ble_evt_t const * p_ble_evt, void * p_context){ if ( p_ble_evt->header.evt_id == BLE_GATTS_EVT_WRITE && p_ble_evt->evt.gatts_evt.params.write.data[0] == 1 ) { // do on subscribe stuff here }}(But surely there must be an easier way?)
thanks