mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-25 09:02:30 +00:00
handle encryption key refresh event
This commit is contained in:
parent
003a27eb00
commit
5f62024dd4
@ -156,6 +156,7 @@ static void att_event_packet_handler (uint8_t packet_type, uint16_t channel, uin
|
|||||||
break;
|
break;
|
||||||
|
|
||||||
case HCI_EVENT_ENCRYPTION_CHANGE:
|
case HCI_EVENT_ENCRYPTION_CHANGE:
|
||||||
|
case HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE:
|
||||||
// check handle
|
// check handle
|
||||||
if (att_connection.con_handle != READ_BT_16(packet, 3)) break;
|
if (att_connection.con_handle != READ_BT_16(packet, 3)) break;
|
||||||
att_connection.encryption_key_size = sm_encryption_key_size(att_client_addr_type, att_client_address);
|
att_connection.encryption_key_size = sm_encryption_key_size(att_client_addr_type, att_client_address);
|
||||||
|
29
ble/sm.c
29
ble/sm.c
@ -1823,6 +1823,35 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case HCI_EVENT_ENCRYPTION_KEY_REFRESH_COMPLETE:
|
||||||
|
handle = READ_BT_16(packet, 3);
|
||||||
|
sm_conn = sm_get_connection_for_handle(handle);
|
||||||
|
if (!sm_conn) break;
|
||||||
|
|
||||||
|
log_info("Encryption key refresh complete, key size %u", sm_conn->sm_connection_encrypted,
|
||||||
|
sm_conn->sm_actual_encryption_key_size);
|
||||||
|
log_info("event handler, state %u", sm_conn->sm_engine_state);
|
||||||
|
// continue if part of initial pairing
|
||||||
|
switch (sm_conn->sm_engine_state){
|
||||||
|
case SM_INITIATOR_PH0_W4_CONNECTION_ENCRYPTED:
|
||||||
|
sm_conn->sm_engine_state = SM_INITIATOR_CONNECTED;
|
||||||
|
sm_done_for_handle(sm_conn->sm_handle);
|
||||||
|
break;
|
||||||
|
case SM_PH2_W4_CONNECTION_ENCRYPTED:
|
||||||
|
if (sm_conn->sm_role){
|
||||||
|
// slave
|
||||||
|
sm_conn->sm_engine_state = SM_PH3_GET_RANDOM;
|
||||||
|
} else {
|
||||||
|
// master
|
||||||
|
sm_conn->sm_engine_state = SM_PH3_RECEIVE_KEYS;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
break;
|
||||||
|
|
||||||
|
|
||||||
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
case HCI_EVENT_DISCONNECTION_COMPLETE:
|
||||||
handle = READ_BT_16(packet, 3);
|
handle = READ_BT_16(packet, 3);
|
||||||
sm_done_for_handle(handle);
|
sm_done_for_handle(handle);
|
||||||
|
Loading…
x
Reference in New Issue
Block a user