aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ports/nrf/drivers/bluetooth/ble_drv.c20
1 files changed, 16 insertions, 4 deletions
diff --git a/ports/nrf/drivers/bluetooth/ble_drv.c b/ports/nrf/drivers/bluetooth/ble_drv.c
index 63af90011..59de7a9c0 100644
--- a/ports/nrf/drivers/bluetooth/ble_drv.c
+++ b/ports/nrf/drivers/bluetooth/ble_drv.c
@@ -1071,12 +1071,24 @@ void SWI2_EGU2_IRQHandler(void) {
sd_evt_handler(evt_id);
}
- uint32_t err_code;
uint16_t evt_len = sizeof(m_ble_evt_buf);
- do {
- err_code = sd_ble_evt_get(m_ble_evt_buf, &evt_len);
+ while (1) {
+ uint32_t err_code = sd_ble_evt_get(m_ble_evt_buf, &evt_len);
+ if (err_code != NRF_SUCCESS) {
+ // Possible error conditions:
+ // * NRF_ERROR_NOT_FOUND: no events left, break
+ // * NRF_ERROR_DATA_SIZE: retry with a bigger data buffer
+ // (currently not handled, TODO)
+ // * NRF_ERROR_INVALID_ADDR: pointer is not aligned, should
+ // not happen.
+ // In all cases, it's best to simply stop now.
+ if (err_code == NRF_ERROR_DATA_SIZE) {
+ BLE_DRIVER_LOG("NRF_ERROR_DATA_SIZE\n");
+ }
+ break;
+ }
ble_evt_handler((ble_evt_t *)m_ble_evt_buf);
- } while (err_code != NRF_ERROR_NOT_FOUND && err_code != NRF_SUCCESS);
+ }
}
#endif // BLUETOOTH_SD