8000 extmod/btstack: Implement GAP scan duration_ms parameter. · micropython/micropython@3d9a7ed · GitHub
[go: up one dir, main page]

Skip to content

Commit 3d9a7ed

Browse files
jimmodpgeorge
authored andcommitted
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.
1 parent 2acc087 commit 3d9a7ed

File tree

1 file changed

+6
-4
lines changed

1 file changed

+6
-4
lines changed

extmod/btstack/modbluetooth_btstack.c

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -889,17 +889,19 @@ int mp_bluetooth_gap_disconnect(uint16_t conn_handle) {
889889
#if MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
890890
STATIC btstack_timer_source_t scan_duration_timeout;
891891

892-
STATIC void hci_initialization_timeout_handler(btstack_timer_source_t *ds) {
892+
STATIC void scan_duration_timeout_handler(btstack_timer_source_t *ds) {
893893
(void)ds;
894894
mp_bluetooth_gap_scan_stop();
895895
}
896896

897897
int mp_bluetooth_gap_scan_start(int32_t duration_ms, int32_t interval_us, int32_t window_us) {
898898
DEBUG_EVENT_printf("mp_bluetooth_gap_scan_start\n");
899899

900-
btstack_run_loop_set_timer(&scan_duration_timeout, duration_ms);
901-
btstack_run_loop_set_timer_handler(&scan_duration_timeout, hci_initialization_timeout_handler);
902-
btstack_run_loop_add_timer(&scan_duration_timeout);
900+
if (duration_ms > 0) {
901+
btstack_run_loop_set_timer(&scan_duration_timeout, duration_ms);
902+
btstack_run_loop_set_timer_handler(&scan_duration_timeout, scan_duration_timeout_handler);
903+
btstack_run_loop_add_timer(&scan_duration_timeout);
904+
}
903905

904906
// 0 = passive scan (we don't handle scan response).
905907
gap_set_scan_parameters(0, interval_us / 625, window_us / 625);

0 commit comments

Comments
 (0)
0