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>
This commit is contained in:
committed by
Damien George
parent
ac89267fef
commit
05fef8c6a4
@@ -359,6 +359,35 @@ STATIC void btstack_packet_handler(uint8_t packet_type, uint8_t *packet, uint8_t
|
||||
DEBUG_printf(" --> btstack # conns changed\n");
|
||||
} else if (event_type == HCI_EVENT_VENDOR_SPECIFIC) {
|
||||
DEBUG_printf(" --> hci vendor specific\n");
|
||||
} else if (event_type == SM_EVENT_AUTHORIZATION_RESULT ||
|
||||
event_type == SM_EVENT_PAIRING_COMPLETE ||
|
||||
// event_type == GAP_EVENT_DEDICATED_BONDING_COMPLETED || // No conn_handle
|
||||
event_type == HCI_EVENT_ENCRYPTION_CHANGE) {
|
||||
DEBUG_printf(" --> enc/auth/pair/bond change\n", );
|
||||
#if MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
|
||||
uint16_t conn_handle;
|
||||
switch (event_type) {
|
||||
case SM_EVENT_AUTHORIZATION_RESULT:
|
||||
conn_handle = sm_event_authorization_result_get_handle(packet);
|
||||
break;
|
||||
case SM_EVENT_PAIRING_COMPLETE:
|
||||
conn_handle = sm_event_pairing_complete_get_handle(packet);
|
||||
break;
|
||||
case HCI_EVENT_ENCRYPTION_CHANGE:
|
||||
conn_handle = hci_event_encryption_change_get_connection_handle(packet);
|
||||
break;
|
||||
default:
|
||||
return;
|
||||
}
|
||||
|
||||
hci_connection_t *hci_con = hci_connection_for_handle(conn_handle);
|
||||
sm_connection_t *desc = &hci_con->sm_connection;
|
||||
mp_bluetooth_gatts_on_encryption_update(conn_handle,
|
||||
desc->sm_connection_encrypted,
|
||||
desc->sm_connection_authenticated,
|
||||
desc->sm_le_db_index != -1,
|
||||
desc->sm_actual_encryption_key_size);
|
||||
#endif // MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING
|
||||
} else if (event_type == HCI_EVENT_DISCONNECTION_COMPLETE) {
|
||||
DEBUG_printf(" --> hci disconnect complete\n");
|
||||
uint16_t conn_handle = hci_event_disconnection_complete_get_connection_handle(packet);
|
||||
|
||||
Reference in New Issue
Block a user