summaryrefslogtreecommitdiff
path: root/extmod/nimble/modbluetooth_nimble.c
diff options
context:
space:
mode:
authorAndrew Leech <andrew.leech@planetinnovation.com.au>2020-11-04 18:21:59 +1100
committerDamien George <damien@micropython.org>2020-12-02 14:40:15 +1100
commit05fef8c6a4113bc05dd09ddd8d0bf7d136d59f39 (patch)
treeb2bb8f26199614ae31fa30aeccedc77ac023baa1 /extmod/nimble/modbluetooth_nimble.c
parentac89267fef8b2396cf46c6ba19ccbe3d10acff9a (diff)
extmod/modbluetooth: Add _IRQ_ENCRYPTION_UPDATE event.
This allows the application to be notified if any of encrypted, authenticated and bonded state change, as well as the encryption key size. Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Diffstat (limited to 'extmod/nimble/modbluetooth_nimble.c')
-rw-r--r--extmod/nimble/modbluetooth_nimble.c24
1 files changed, 24 insertions, 0 deletions
diff --git a/extmod/nimble/modbluetooth_nimble.c b/extmod/nimble/modbluetooth_nimble.c
index e79dc2d4c..312a56426 100644
--- a/extmod/nimble/modbluetooth_nimble.c
+++ b/extmod/nimble/modbluetooth_nimble.c
@@ -316,6 +316,19 @@ STATIC int gap_event_cb(struct ble_gap_event *event, void *arg) {
}
break;
}
+
+ case BLE_GAP_EVENT_ENC_CHANGE: {
+ DEBUG_printf("gap_event_cb: enc change: status=%d\n", event->enc_change.status);
+ #if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
+ struct ble_gap_conn_desc desc;
+ if (ble_gap_conn_find(event->enc_change.conn_handle, &desc) == 0) {
+ mp_bluetooth_gatts_on_encryption_update(event->conn_update.conn_handle,
+ desc.sec_state.encrypted, desc.sec_state.authenticated,
+ desc.sec_state.bonded, desc.sec_state.key_size);
+ }
+ #endif
+ break;
+ }
}
return 0;
}
@@ -971,6 +984,17 @@ STATIC int peripheral_gap_event_cb(struct ble_gap_event *event, void *arg) {
break;
}
+ case BLE_GAP_EVENT_ENC_CHANGE: {
+ DEBUG_printf("peripheral_gap_event_cb: enc change: status=%d\n", event->enc_change.status);
+ #if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
+ if (ble_gap_conn_find(event->enc_change.conn_handle, &desc) == 0) {
+ mp_bluetooth_gatts_on_encryption_update(event->conn_update.conn_handle,
+ desc.sec_state.encrypted, desc.sec_state.authenticated,
+ desc.sec_state.bonded, desc.sec_state.key_size);
+ }
+ #endif
+ break;
+ }
default:
break;
}