Skip to content

Commit 8cef3d2

Browse files
authored
Merge pull request #5321 from tannewt/fix_scan_after_p_bond
Fix scanning after a peripheral bond has been made
2 parents cfc4ed1 + 2b4fdcd commit 8cef3d2

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)