Skip to content

Commit 86f8210

Browse files
committed
nordic/bluetooth/ble_drv.c: gc entire event handler list
1 parent c296935 commit 86f8210

File tree

3 files changed

+12
-2
lines changed

3 files changed

+12
-2
lines changed

ports/nordic/bluetooth/ble_drv.c

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ volatile sd_flash_operation_status_t sd_flash_operation_status;
3131
__attribute__((aligned(4)))
3232
static uint8_t m_ble_evt_buf[sizeof(ble_evt_t) + (BLE_GATTS_VAR_ATTR_LEN_MAX)];
3333

34-
void ble_drv_reset() {
34+
void ble_drv_reset(void) {
3535
// Linked list items will be gc'd.
3636
MP_STATE_VM(ble_drv_evt_handler_entries) = NULL;
3737
sd_flash_operation_status = SD_FLASH_OPERATION_DONE;
@@ -136,7 +136,7 @@ void SD_EVT_IRQHandler(void) {
136136
const uint32_t err_code = sd_ble_evt_get(m_ble_evt_buf, &evt_len);
137137
if (err_code != NRF_SUCCESS) {
138138
if (err_code == NRF_ERROR_DATA_SIZE) {
139-
printf("NRF_ERROR_DATA_SIZE\n");
139+
mp_printf(&mp_plat_print, "NRF_ERROR_DATA_SIZE\n");
140140
}
141141

142142
break;
@@ -177,4 +177,12 @@ void SD_EVT_IRQHandler(void) {
177177
#endif
178178
}
179179

180+
void ble_drv_gc_collect(void) {
181+
ble_drv_evt_handler_entry_t *it = MP_STATE_VM(ble_drv_evt_handler_entries);
182+
while (it != NULL) {
183+
gc_collect_ptr(it);
184+
it = it->next;
185+
}
186+
}
187+
180188
MP_REGISTER_ROOT_POINTER(ble_drv_evt_handler_entry_t * ble_drv_evt_handler_entries);

ports/nordic/bluetooth/ble_drv.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ void ble_drv_reset(void);
4949
void ble_drv_remove_heap_handlers(void);
5050
void ble_drv_add_event_handler(ble_drv_evt_handler_t func, void *param);
5151
void ble_drv_remove_event_handler(ble_drv_evt_handler_t func, void *param);
52+
void ble_drv_gc_collect(void);
5253

5354
// Allow for user provided entries to prevent allocations outside the VM.
5455
void ble_drv_add_event_handler_entry(ble_drv_evt_handler_entry_t *entry, ble_drv_evt_handler_t func, void *param);

ports/nordic/common-hal/_bleio/__init__.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -248,4 +248,5 @@ void bleio_background(void) {
248248

249249
void common_hal_bleio_gc_collect(void) {
250250
bleio_adapter_gc_collect(&common_hal_bleio_adapter_obj);
251+
ble_drv_gc_collect();
251252
}

0 commit comments

Comments
 (0)