mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 03:35:20 +00:00
track encryption status
This commit is contained in:
parent
cb230b9da5
commit
f0944df2d0
25
src/hci.c
25
src/hci.c
@ -685,6 +685,19 @@ static void event_handler(uint8_t *packet, int size){
|
||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[2], SEND_USER_PASSKEY_REPLY);
|
||||
break;
|
||||
|
||||
case HCI_EVENT_ENCRYPTION_CHANGE:
|
||||
if (packet[2]) break; // error status
|
||||
handle = READ_BT_16(packet, 3);
|
||||
conn = hci_connection_for_handle(handle);
|
||||
if (!conn) break;
|
||||
if (packet[5]){
|
||||
conn->authentication_flags |= CONNECTION_ENCRYPTED;
|
||||
// @TODO set authentication depending on pairing process
|
||||
} else {
|
||||
conn->authentication_flags &= ~(CONNECTION_ENCRYPTED | CONNECTION_AUTHENTICATED);
|
||||
}
|
||||
break;
|
||||
|
||||
#ifndef EMBEDDED
|
||||
case HCI_EVENT_REMOTE_NAME_REQUEST_COMPLETE:
|
||||
if (!hci_stack.remote_device_db) break;
|
||||
@ -1509,12 +1522,12 @@ int hci_send_cmd_packet(uint8_t *packet, int size){
|
||||
if (IS_COMMAND(packet, hci_link_key_request_negative_reply)){
|
||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[3], SENT_LINK_KEY_NEGATIVE_REQUEST);
|
||||
}
|
||||
if (IS_COMMAND(packet, hci_pin_code_request_reply)){
|
||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[3], SENT_PIN_CODE_REPLY);
|
||||
}
|
||||
if (IS_COMMAND(packet, hci_pin_code_request_negative_reply)){
|
||||
hci_add_connection_flags_for_flipped_bd_addr(&packet[3], SENT_PIN_CODE_NEGATIVE_REPLY);
|
||||
}
|
||||
// if (IS_COMMAND(packet, hci_pin_code_request_reply)){
|
||||
// hci_add_connection_flags_for_flipped_bd_addr(&packet[3], SENT_PIN_CODE_REPLY);
|
||||
// }
|
||||
// if (IS_COMMAND(packet, hci_pin_code_request_negative_reply)){
|
||||
// hci_add_connection_flags_for_flipped_bd_addr(&packet[3], SENT_PIN_CODE_NEGATIVE_REPLY);
|
||||
// }
|
||||
|
||||
if (IS_COMMAND(packet, hci_delete_stored_link_key)){
|
||||
if (hci_stack.remote_device_db){
|
||||
|
26
src/hci.h
26
src/hci.h
@ -207,15 +207,20 @@ typedef enum {
|
||||
RECV_LINK_KEY_NOTIFICATION = 0x0010,
|
||||
RECV_PIN_CODE_REQUEST = 0x0020,
|
||||
HANDLE_PIN_CODE_REQUEST = 0x0040,
|
||||
SENT_PIN_CODE_REPLY = 0x0080,
|
||||
SENT_PIN_CODE_NEGATIVE_REPLY = 0x0100,
|
||||
// SSP
|
||||
RECV_IO_CAPABILITIES_REQUEST = 0x0200,
|
||||
SEND_IO_CAPABILITIES_REPLY = 0x0400,
|
||||
RECV_USER_CONFIRM_REQUEST = 0x0800,
|
||||
SEND_USER_CONFIRM_REPLY = 0x1000,
|
||||
RECV_USER_PASSKEY_REQUEST = 0x2000,
|
||||
SEND_USER_PASSKEY_REPLY = 0x4000,
|
||||
RECV_IO_CAPABILITIES_REQUEST = 0x0080,
|
||||
SEND_IO_CAPABILITIES_REPLY = 0x0100,
|
||||
RECV_USER_CONFIRM_REQUEST = 0x0200,
|
||||
SEND_USER_CONFIRM_REPLY = 0x0400,
|
||||
RECV_USER_PASSKEY_REQUEST = 0x0800,
|
||||
SEND_USER_PASSKEY_REPLY = 0x1000,
|
||||
// connection status
|
||||
CONNECTION_ENCRYPTED = 0x2000,
|
||||
CONNECTION_AUTHENTICATED = 0x4000,
|
||||
|
||||
// SENT_PIN_CODE_REPLY = 0x0080,
|
||||
// SENT_PIN_CODE_NEGATIVE_REPLY = 0x0100,
|
||||
|
||||
} hci_authentication_flags_t;
|
||||
|
||||
typedef enum {
|
||||
@ -233,6 +238,9 @@ typedef enum {
|
||||
BONDING_REMOTE_SUPPORTS_SSP = 0x04,
|
||||
} bonding_flags_t;
|
||||
|
||||
#define CHANNEL_SECURITY_ENCRYPTED = 0x01
|
||||
#define CHANNEL_SECURITY_AUTHENTICAED = 0x02
|
||||
|
||||
typedef enum {
|
||||
BLUETOOTH_OFF = 1,
|
||||
BLUETOOTH_ON,
|
||||
@ -253,7 +261,7 @@ typedef struct {
|
||||
CONNECTION_STATE state;
|
||||
|
||||
// bonding
|
||||
bonding_flags_t bonding_flags;
|
||||
bonding_flags_t bonding_flags;
|
||||
|
||||
// errands
|
||||
hci_authentication_flags_t authentication_flags;
|
||||
|
Loading…
x
Reference in New Issue
Block a user