/**@brief Function for fetching BLE events from the S110 Stack. * * @param[in] p_event_data Unused by this function. * @param[in] event_size Unused by this function. */ static void stack_evt_get(void * p_event_data, uint16_t event_size) { // This function expects the p_event_data and event_size to be zero. This function will fetch // the event from the S110 Stack. UNUSED_PARAMETER(p_event_data); UNUSED_PARAMETER(event_size); for (;;) { uint32_t err_code; uint16_t evt_len = sizeof(m_evt_buffer); // Pull the event from stack. err_code = sd_ble_evt_get((uint8_t *) m_evt_buffer, &evt_len); if ((err_code == NRF_ERROR_NOT_FOUND) || (err_code == NRF_ERROR_SOFTDEVICE_NOT_ENABLED)) { // Either there are no more events OR the S110 Stack has been disabled. This additional // error code check is the only difference between this function and @ref // ble_stack_evt_get. This check is needed because the bootloader may have disabled // the S110 stack after finishing the firmware update. break; } else if (err_code != NRF_SUCCESS) { APP_ERROR_HANDLER(err_code); } // Call the BLE stack event handler. ble_evt_dispatch((ble_evt_t *)m_evt_buffer); } }
void SD_EVT_IRQHandler(void) { uint8_t evt_buf[sizeof(ble_evt_t) + BLE_L2CAP_MTU_DEF]; uint16_t evt_len; ble_evt_t *p_ble_evt = (ble_evt_t *) evt_buf; uint32_t event; while ( sd_evt_get(&event) == NRF_SUCCESS ) { sys_evt_dispatch(event); } evt_len = sizeof(evt_buf); while (sd_ble_evt_get(evt_buf, &evt_len) == NRF_SUCCESS) { ble_evt_dispatch(p_ble_evt); evt_len = sizeof(evt_buf); } }