I notice that for everything related to a BLE connection in the nRF code, there is a "connection handle". Usually, the handle is zero. When is the connection handle NOT zero? I ask because my code looks messier if I have to keep an array of connection handles. If my nRF is just a peripheral, then it can only have one connection at once, right? A peripheral stops advertising upon connection, so it can never have more than one connection, right?
I am trying to look up the data length for my current connection too. Where do I do that? Do I make an event handler like this and store the data length separately, or can I look it up on-demand with my connection handle?
/**@brief Function for handling events from the GATT library. */ static void gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t const * p_evt) { (void) p_gatt; //UNUSED uint16_t conn_handle = p_evt->conn_handle; switch (p_evt->evt_id) { case NRF_BLE_GATT_EVT_ATT_MTU_UPDATED: { NRF_LOG_INFO("ATT MTU exchange completed. MTU set to %u bytes.", p_evt->params.att_mtu_effective); NRF_LOG_INFO("Data length is %u bytes.", p_evt->params.data_length); } break; case NRF_BLE_GATT_EVT_DATA_LENGTH_UPDATED: { NRF_LOG_INFO("Data length updated to %u bytes.", p_evt->params.data_length); } break; } }