mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-16 08:42:28 +00:00
sm: add SM_RESPONDER_PH4_W4_CONNECTION_ENCRYPTED and handle with peripheral role to emit re-encryption complete event
This commit is contained in:
parent
42646f3875
commit
8d4eef95e2
@ -2765,9 +2765,8 @@ static void sm_run(void){
|
|||||||
case SM_RESPONDER_PH4_SEND_LTK_REPLY: {
|
case SM_RESPONDER_PH4_SEND_LTK_REPLY: {
|
||||||
sm_key_t ltk_flipped;
|
sm_key_t ltk_flipped;
|
||||||
reverse_128(setup->sm_ltk, ltk_flipped);
|
reverse_128(setup->sm_ltk, ltk_flipped);
|
||||||
connection->sm_engine_state = SM_RESPONDER_IDLE;
|
connection->sm_engine_state = SM_RESPONDER_PH4_W4_CONNECTION_ENCRYPTED;
|
||||||
hci_send_cmd(&hci_le_long_term_key_request_reply, connection->sm_handle, ltk_flipped);
|
hci_send_cmd(&hci_le_long_term_key_request_reply, connection->sm_handle, ltk_flipped);
|
||||||
sm_done_for_handle(connection->sm_handle);
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3500,10 +3499,15 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
|
|||||||
switch (sm_conn->sm_engine_state){
|
switch (sm_conn->sm_engine_state){
|
||||||
|
|
||||||
case SM_INITIATOR_PH0_W4_CONNECTION_ENCRYPTED:
|
case SM_INITIATOR_PH0_W4_CONNECTION_ENCRYPTED:
|
||||||
|
case SM_RESPONDER_PH4_W4_CONNECTION_ENCRYPTED:
|
||||||
// encryption change event concludes re-encryption for bonded devices (even if it fails)
|
// encryption change event concludes re-encryption for bonded devices (even if it fails)
|
||||||
if (sm_conn->sm_connection_encrypted) {
|
if (sm_conn->sm_connection_encrypted) {
|
||||||
status = ERROR_CODE_SUCCESS;
|
status = ERROR_CODE_SUCCESS;
|
||||||
|
if (sm_conn->sm_role){
|
||||||
|
sm_conn->sm_engine_state = SM_RESPONDER_IDLE;
|
||||||
|
} else {
|
||||||
sm_conn->sm_engine_state = SM_INITIATOR_CONNECTED;
|
sm_conn->sm_engine_state = SM_INITIATOR_CONNECTED;
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
status = ERROR_CODE_AUTHENTICATION_FAILURE;
|
status = ERROR_CODE_AUTHENTICATION_FAILURE;
|
||||||
// set state to 'TIMEOUT' to prevent further interaction with this
|
// set state to 'TIMEOUT' to prevent further interaction with this
|
||||||
|
@ -335,6 +335,7 @@ typedef enum {
|
|||||||
// Phase 4: re-establish previously distributed LTK
|
// Phase 4: re-establish previously distributed LTK
|
||||||
SM_RESPONDER_PH4_Y_W4_ENC,
|
SM_RESPONDER_PH4_Y_W4_ENC,
|
||||||
SM_RESPONDER_PH4_SEND_LTK_REPLY,
|
SM_RESPONDER_PH4_SEND_LTK_REPLY,
|
||||||
|
SM_RESPONDER_PH4_W4_CONNECTION_ENCRYPTED,
|
||||||
|
|
||||||
// INITITIATOR ROLE
|
// INITITIATOR ROLE
|
||||||
SM_INITIATOR_CONNECTED,
|
SM_INITIATOR_CONNECTED,
|
||||||
|
Loading…
x
Reference in New Issue
Block a user