summaryrefslogtreecommitdiff
path: root/extmod/nimble/modbluetooth_nimble.c
diff options
context:
space:
mode:
authorJim Mussared <jim.mussared@gmail.com>2020-11-24 23:54:46 +1100
committerDamien George <damien@micropython.org>2020-12-02 14:40:49 +1100
commita1fcf301217b34ae74fbb937a9488be5bc6e61a5 (patch)
tree0625c5cabd5c5072c35e43b4ba0c6688d34e3fef /extmod/nimble/modbluetooth_nimble.c
parent05fef8c6a4113bc05dd09ddd8d0bf7d136d59f39 (diff)
extmod/modbluetooth: Allow configuration of pairing/bonding parameters.
This allows setting the security and MITM-protection requirements. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'extmod/nimble/modbluetooth_nimble.c')
-rw-r--r--extmod/nimble/modbluetooth_nimble.c18
1 files changed, 18 insertions, 0 deletions
diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c
index 312a56426..852b9eac0 100644
--- a/extmod/nimble/modbluetooth_nimble.c
+++ b/extmod/nimble/modbluetooth_nimble.c
@@ -552,6 +552,24 @@ void mp_bluetooth_set_address_mode(uint8_t addr_mode) {
}
}
+#if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
+void mp_bluetooth_set_bonding(bool enabled) {
+ ble_hs_cfg.sm_bonding = enabled;
+}
+
+void mp_bluetooth_set_mitm_protection(bool enabled) {
+ ble_hs_cfg.sm_mitm = enabled;
+}
+
+void mp_bluetooth_set_le_secure(bool enabled) {
+ ble_hs_cfg.sm_sc = enabled;
+}
+
+void mp_bluetooth_set_io_capability(uint8_t capability) {
+ ble_hs_cfg.sm_io_cap = capability;
+}
+#endif // MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
+
size_t mp_bluetooth_gap_get_device_name(const uint8_t **buf) {
const char *name = ble_svc_gap_device_name();
*buf = (const uint8_t *)name;