diff options
author | Jim Mussared <jim.mussared@gmail.com> | 2020-11-24 23:54:46 +1100 |
---|---|---|
committer | Damien George <damien@micropython.org> | 2020-12-02 14:40:49 +1100 |
commit | a1fcf301217b34ae74fbb937a9488be5bc6e61a5 (patch) | |
tree | 0625c5cabd5c5072c35e43b4ba0c6688d34e3fef /extmod/modbluetooth.c | |
parent | 05fef8c6a4113bc05dd09ddd8d0bf7d136d59f39 (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/modbluetooth.c')
-rw-r--r-- | extmod/modbluetooth.c | 22 |
1 files changed, 22 insertions, 0 deletions
diff --git a/extmod/modbluetooth.c b/extmod/modbluetooth.c index 5d7de7b97..06e340c42 100644 --- a/extmod/modbluetooth.c +++ b/extmod/modbluetooth.c @@ -387,6 +387,28 @@ STATIC mp_obj_t bluetooth_ble_config(size_t n_args, const mp_obj_t *args, mp_map mp_bluetooth_set_address_mode(addr_mode); break; } + #if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING + case MP_QSTR_bond: { + bool bonding_enabled = mp_obj_is_true(e->value); + mp_bluetooth_set_bonding(bonding_enabled); + break; + } + case MP_QSTR_mitm: { + bool mitm_protection = mp_obj_is_true(e->value); + mp_bluetooth_set_mitm_protection(mitm_protection); + break; + } + case MP_QSTR_io: { + mp_int_t io_capability = mp_obj_get_int(e->value); + mp_bluetooth_set_io_capability(io_capability); + break; + } + case MP_QSTR_le_secure: { + bool le_secure_required = mp_obj_is_true(e->value); + mp_bluetooth_set_le_secure(le_secure_required); + break; + } + #endif // MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING default: mp_raise_ValueError(MP_ERROR_TEXT("unknown config param")); } |