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>
This commit is contained in:
Jim Mussared
2020-11-24 23:54:46 +11:00
committed by Damien George
parent 05fef8c6a4
commit a1fcf30121
5 changed files with 109 additions and 6 deletions

View File

@@ -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;