extmod/btstack: Implement GAP scan duration_ms parameter.
This commit makes scanning work when duration_ms is set to zero. Prior to this it would not work with duration_ms set to zero.
This commit is contained in:
parent
2acc087880
commit
3d9a7ed02f
@ -889,7 +889,7 @@ int mp_bluetooth_gap_disconnect(uint16_t conn_handle) {
|
||||
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
|
||||
STATIC btstack_timer_source_t scan_duration_timeout;
|
||||
|
||||
STATIC void hci_initialization_timeout_handler(btstack_timer_source_t *ds) {
|
||||
STATIC void scan_duration_timeout_handler(btstack_timer_source_t *ds) {
|
||||
(void)ds;
|
||||
mp_bluetooth_gap_scan_stop();
|
||||
}
|
||||
@ -897,9 +897,11 @@ STATIC void hci_initialization_timeout_handler(btstack_timer_source_t *ds) {
|
||||
int mp_bluetooth_gap_scan_start(int32_t duration_ms, int32_t interval_us, int32_t window_us) {
|
||||
DEBUG_EVENT_printf("mp_bluetooth_gap_scan_start\n");
|
||||
|
||||
if (duration_ms > 0) {
|
||||
btstack_run_loop_set_timer(&scan_duration_timeout, duration_ms);
|
||||
btstack_run_loop_set_timer_handler(&scan_duration_timeout, hci_initialization_timeout_handler);
|
||||
btstack_run_loop_set_timer_handler(&scan_duration_timeout, scan_duration_timeout_handler);
|
||||
btstack_run_loop_add_timer(&scan_duration_timeout);
|
||||
}
|
||||
|
||||
// 0 = passive scan (we don't handle scan response).
|
||||
gap_set_scan_parameters(0, interval_us / 625, window_us / 625);
|
||||
|
Loading…
Reference in New Issue
Block a user