I've tried getting a notification of subscription from a bluetooth event handler like so:
-
ble_evt_dispatch() is being called from main:
static void ble_evt_dispatch(ble_evt_t * p_ble_evt) { on_ble_evt(p_ble_evt); ble_conn_params_on_ble_evt(p_ble_evt); ble_MY_SERVICE_on_ble_evt(&MY_SERVICE_handle, p_ble_evt); // <- My service's event handler }
-
My service's event handler does some crude event matching:
void ble_MY_SERVICE_on_ble_evt(MY_SERVICE_handle_t *MY_SERVICE_handle, ble_evt_t *p_ble_evt) { switch (p_ble_evt->header.evt_id) { case BLE_GAP_EVT_CONNECTED: case BLE_GAP_EVT_DISCONNECTED: .... case ???: { ??? } break; } }
At this point I'm stuck. When subscribing to a characteristic, p_ble_evt->header.evt_id equals to 0x0050, but since enums don't have explicit values in the code, I don't know which event this corresponds to and how to handle it.
And if I try and bruteforce it by hardcoding 0x0050 event handling, p_ble_evt->evt.gattc_evt.params.hvx.type always equals to 0xF1, which doesn't make sense since this parameter is of 'type' BLE_GATT_HVX_TYPES which can only be 0x00, 0x01 or 0x02, so I must be doing something wrong since I think its just garbage data.