summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-11-25 19:26:56 +1100
committerDamien George <damien@micropython.org>2020-12-02 14:39:41 +1100
commitac89267fef8b2396cf46c6ba19ccbe3d10acff9a (patch)
tree31c78500c09f9d471e51948d3b3194b08e050115
parent5e20f689ada17dcd750d516c957115fbb36c9435 (diff)
extmod/modbluetooth: Add compile-config flag to enable pairing/bonding.
Enable it on STM32/Unix NimBLE only (pairing/bonding requires synchronous events and full bindings). Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
-rw-r--r--extmod/modbluetooth.c4
-rw-r--r--extmod/modbluetooth.h6
-rw-r--r--extmod/nimble/nimble.mk5
3 files changed, 15 insertions, 0 deletions
diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c
index ed983b794..b9b7c7124 100644
--- a/extmod/modbluetooth.c
+++ b/extmod/modbluetooth.c
@@ -47,6 +47,10 @@
#error l2cap channels require synchronous modbluetooth events
#endif
+#if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING && !MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS
+#error pairing and bonding require synchronous modbluetooth events
+#endif
+
#define MP_BLUETOOTH_CONNECT_DEFAULT_SCAN_DURATION_MS 2000
#define MICROPY_PY_BLUETOOTH_MAX_EVENT_DATA_TUPLE_LEN 5
diff --git a/extmod/modbluetooth.h b/extmod/modbluetooth.h
index 9856d4a68..2cb2c709c 100644
--- a/extmod/modbluetooth.h
+++ b/extmod/modbluetooth.h
@@ -54,6 +54,12 @@
#define MICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS (0)
#endif
+// A port can optionally enable support for pairing and bonding.
+// Requires MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS.
+#ifndef MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
+#define MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING (0)
+#endif
+
// This is used to protect the ringbuffer.
// A port may no-op this if MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS is enabled.
#ifndef MICROPY_PY_BLUETOOTH_ENTER
diff --git a/extmod/nimble/nimble.mk b/extmod/nimble/nimble.mk
index 00a244d6e..ba094f16f 100644
--- a/extmod/nimble/nimble.mk
+++ b/extmod/nimble/nimble.mk
@@ -24,6 +24,11 @@ ifeq ($(MICROPY_BLUETOOTH_NIMBLE_BINDINGS_ONLY),0)
# UART is also polled by the RX IRQ.
CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS=1
+# Without the ringbuffer, and with the full implementation, we can also
+# enable pairing and bonding. This requires both synchronous events and
+# some customisation of the key store.
+CFLAGS_MOD += -DMICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING=1
+
NIMBLE_LIB_DIR = lib/mynewt-nimble
LIB_SRC_C += $(addprefix $(NIMBLE_LIB_DIR)/, \