summaryrefslogtreecommitdiffstatshomepage
path: root/extmod/btstack/modbluetooth_btstack.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-08-14 15:43:37 +1000
committerDamien George <damien@micropython.org>2020-08-26 14:55:52 +1000
commit3d9a7ed02f4e50ee2eb541ac2f4d7f6f5b5d316e (patch)
treedf6512431ace76feaa1f8753052d755d58b61f65 /extmod/btstack/modbluetooth_btstack.c
parent2acc087880de39d7e17abc9344b8d2faba3478dd (diff)
downloadmicropython-3d9a7ed02f4e50ee2eb541ac2f4d7f6f5b5d316e.tar.gz
micropython-3d9a7ed02f4e50ee2eb541ac2f4d7f6f5b5d316e.zip
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.
Diffstat (limited to 'extmod/btstack/modbluetooth_btstack.c')
-rw-r--r--extmod/btstack/modbluetooth_btstack.c10
1 files changed, 6 insertions, 4 deletions
diff --git a/extmod/btstack/modbluetooth_btstack.c b/extmod/btstack/modbluetooth_btstack.c
index c7269d33ed..89e396dfd0 100644
--- a/extmod/btstack/modbluetooth_btstack.c
+++ b/extmod/btstack/modbluetooth_btstack.c
@@ -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");
- 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_add_timer(&scan_duration_timeout);
+ if (duration_ms > 0) {
+ btstack_run_loop_set_timer(&scan_duration_timeout, duration_ms);
+ 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);