diff --git a/src/gap.h b/src/gap.h index b3f713eba..7bf584e11 100644 --- a/src/gap.h +++ b/src/gap.h @@ -82,7 +82,6 @@ typedef enum { void gap_set_bondable_mode(int enabled); gap_security_level_t gap_security_level_for_link_key_type(link_key_type_t link_key_type); -gap_security_level_t gap_security_level_for_connection(hci_connection_t * connection); gap_security_level_t gap_security_level(hci_con_handle_t con_handle); void gap_request_security_level(hci_con_handle_t con_handle, gap_security_level_t level); diff --git a/src/hci.c b/src/hci.c index 587e35ecc..bf7cbe6df 100644 --- a/src/hci.c +++ b/src/hci.c @@ -705,15 +705,15 @@ static void event_handler(uint8_t *packet, int size){ } break; - case HCI_EVENT_AUTHENTICATION_COMPLETE: - handle = READ_BT_16(packet, 3); - conn = hci_connection_for_handle(handle); - if (!conn) break; - if (conn->bonding_flags->BONDING_REQUESTED){ - gap_security_level_t level = gap_security_level_for_connection(conn); - hci_emit_security_level(handle, packet[2], level); - } - break; + // case HCI_EVENT_AUTHENTICATION_COMPLETE_EVENT: + // handle = READ_BT_16(packet, 3); + // conn = hci_connection_for_handle(handle); + // if (!conn) break; + // if (conn->bonding_flags & BONDING_REQUESTED){ + // gap_security_level_t level = gap_security_level_for_connection(conn); + // hci_emit_security_level(handle, packet[2], level); + // } + // break; #ifndef EMBEDDED case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE: @@ -1297,6 +1297,11 @@ void hci_run(){ hci_send_cmd(&hci_authentication_requested, connection->con_handle); return; } + if (connection->bonding_flags & BONDING_SEND_ENCRYPTION_REQUEST){ + connection->bonding_flags &= ~BONDING_SEND_ENCRYPTION_REQUEST; + hci_send_cmd(&hci_set_connection_encryption, connection->con_handle, 1); + return; + } } switch (hci_stack.state){ diff --git a/src/hci.h b/src/hci.h index e5f63e23d..fe68fcb0e 100644 --- a/src/hci.h +++ b/src/hci.h @@ -239,6 +239,7 @@ typedef enum { BONDING_DISCONNECT_SECURITY_BLOCK = 0x08, BONDING_REQUESTED = 0x10, BONDING_SEND_AUTHENTICATE_REQUEST = 0x20, + BONDING_SEND_ENCRYPTION_REQUEST = 0x40, } bonding_flags_t; typedef enum {