summaryrefslogtreecommitdiff
path: root/extmod/modbluetooth.c
diff options
context:
space:
mode:
authorAndrew Leech <andrew.leech@planetinnovation.com.au>2020-08-14 11:49:41 +1000
committerDamien George <damien@micropython.org>2020-08-26 15:00:11 +1000
commita80a146858b3c9a7fbae4030a524666ab19f7a47 (patch)
tree0de2574a6e87c825fe60212dfc5db374cdd8154f /extmod/modbluetooth.c
parent0bc2c1c1057d7f5c1e4987139062386a8f9fe5f2 (diff)
extmod/bluetooth: Support active scanning in BLE.gap_scan().
This adds an additional optional parameter to gap_scan() to select active scanning, where scan responses are returned as well as normal scan results. This parameter is False by default which retains the existing behaviour.
Diffstat (limited to 'extmod/modbluetooth.c')
-rw-r--r--extmod/modbluetooth.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c
index 730c288ee..82efe4938 100644
--- a/extmod/modbluetooth.c
+++ b/extmod/modbluetooth.c
@@ -609,6 +609,7 @@ STATIC mp_obj_t bluetooth_ble_gap_scan(size_t n_args, const mp_obj_t *args) {
mp_int_t duration_ms = 0;
mp_int_t interval_us = 1280000;
mp_int_t window_us = 11250;
+ bool active_scan = false;
if (n_args > 1) {
if (args[1] == mp_const_none) {
// scan(None) --> stop scan.
@@ -619,12 +620,15 @@ STATIC mp_obj_t bluetooth_ble_gap_scan(size_t n_args, const mp_obj_t *args) {
interval_us = mp_obj_get_int(args[2]);
if (n_args > 3) {
window_us = mp_obj_get_int(args[3]);
+ if (n_args > 4) {
+ active_scan = mp_obj_is_true(args[4]);
+ }
}
}
}
- return bluetooth_handle_errno(mp_bluetooth_gap_scan_start(duration_ms, interval_us, window_us));
+ return bluetooth_handle_errno(mp_bluetooth_gap_scan_start(duration_ms, interval_us, window_us, active_scan));
}
-STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bluetooth_ble_gap_scan_obj, 1, 4, bluetooth_ble_gap_scan);
+STATIC MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(bluetooth_ble_gap_scan_obj, 1, 5, bluetooth_ble_gap_scan);
#endif // MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE
STATIC mp_obj_t bluetooth_ble_gap_disconnect(mp_obj_t self_in, mp_obj_t conn_handle_in) {