8000 Fix scanning after a peripheral bond has been made · urish/circuitpython@2b4fdcd · GitHub
[go: up one dir, main page]

Skip to content

Commit 2b4fdcd

Browse files
committed
Fix scanning after a peripheral bond has been made
The BLE workflow will be advertising and the scan's load of identities conflicts with it. This change ensures scanning and advertising happens exclusively. This showed as an unknown error 3204. Fixes adafruit/Adafruit_CircuitPython_BLE#134
1 parent cfc4ed1 commit 2b4fdcd

File tree

1 file changed

+10
-0
lines changed

1 file changed

+10
-0
lines changed

ports/nrf/common-hal/_bleio/Adapter.c

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,16 @@ mp_obj_t common_hal_bleio_adapter_start_scan(bleio_adapter_obj_t *self, uint8_t
507507
}
508508
self->scan_results = NULL;
509509
}
510+
// Check to see if advertising is going already.
511+
if (self->current_advertising_data != NULL && self->current_advertising_data == self->advertising_data) {
512+
check_nrf_error(NRF_ERROR_BUSY);
513+
}
514+
515+
// If the current advertising data isn't owned by the adapter then it must be an internal
516+
// advertisement that we should stop.
517+
if (self->current_advertising_data != NULL) {
518+
common_hal_bleio_adapter_stop_advertising(self);
519+
}
510520
self->scan_results = shared_module_bleio_new_scanresults(buffer_size, prefixes, prefix_length, minimum_rssi);
511521
size_t max_packet_size = extended ? BLE_GAP_SCAN_BUFFER_EXTENDED_MAX_SUPPORTED : BLE_GAP_SCAN_BUFFER_MAX;
512522
uint8_t *raw_data = m_malloc(sizeof(ble_data_t) + max_packet_size, false);

0 commit comments

Comments
 (0)
0