allow to send connection encryption command

This commit is contained in:
matthias.ringwald@gmail.com 2014-01-17 09:45:07 +00:00
parent 34d2123c9e
commit dce7800923
3 changed files with 15 additions and 10 deletions

View File

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

View File

@ -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){

View File

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