I'm looking at the ble_app_hrs example and I'm confused about how the drivers are able to differentiate between events originating from various services/characteristics. For example, in main.c under the ble_evt_dispatch we have:
void ble_evt_dispatch(ble_evt_t * p_ble_evt)
{
dm_ble_evt_handler(p_ble_evt);
ble_hrs_on_ble_evt(&m_hrs, p_ble_evt);
ble_bas_on_ble_evt(&m_bas, p_ble_evt);
ble_conn_params_on_ble_evt(p_ble_evt);
on_ble_evt(p_ble_evt);
}
So on any ble event the ble_bas_on_ble_evt function will be called, with the p_ble_evt
void ble_bas_on_ble_evt(ble_bas_t * p_bas, ble_evt_t * p_ble_evt) {
switch (p_ble_evt->header.evt_id) {
case BLE_GAP_EVT_CONNECTED:
on_connect(p_bas, p_ble_evt);
break;
...
}
}
Which in turn calls on_connect which associates the handle of the event with the BAS
static void on_connect(ble_bas_t * p_bas, ble_evt_t * p_ble_evt)
{
p_bas->conn_handle = p_ble_evt->evt.gap_evt.conn_handle;
}
My question is where does it differentiate between the source of the event, so that it doesn't store the handle every time anything triggers a BLE_GAP_EVT_CONNECTED event.