mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-02-21 12:40:42 +00:00
sm: use switch in sm_request_pairing
This commit is contained in:
parent
41ce31d997
commit
175b7faa75
55
src/ble/sm.c
55
src/ble/sm.c
@ -4373,32 +4373,37 @@ void sm_request_pairing(hci_con_handle_t con_handle){
|
|||||||
sm_send_security_request_for_connection(sm_conn);
|
sm_send_security_request_for_connection(sm_conn);
|
||||||
} else {
|
} else {
|
||||||
// used as a trigger to start central/master/initiator security procedures
|
// used as a trigger to start central/master/initiator security procedures
|
||||||
if (sm_conn->sm_engine_state == SM_INITIATOR_CONNECTED){
|
bool have_ltk;
|
||||||
uint8_t ltk[16];
|
uint8_t ltk[16];
|
||||||
bool have_ltk;
|
switch (sm_conn->sm_engine_state){
|
||||||
switch (sm_conn->sm_irk_lookup_state){
|
case SM_INITIATOR_CONNECTED:
|
||||||
case IRK_LOOKUP_SUCCEEDED:
|
switch (sm_conn->sm_irk_lookup_state){
|
||||||
le_device_db_encryption_get(sm_conn->sm_le_db_index, NULL, NULL, ltk, NULL, NULL, NULL, NULL);
|
case IRK_LOOKUP_SUCCEEDED:
|
||||||
have_ltk = !sm_is_null_key(ltk);
|
le_device_db_encryption_get(sm_conn->sm_le_db_index, NULL, NULL, ltk, NULL, NULL, NULL, NULL);
|
||||||
log_info("have ltk %u", have_ltk);
|
have_ltk = !sm_is_null_key(ltk);
|
||||||
if (have_ltk){
|
log_info("have ltk %u", have_ltk);
|
||||||
sm_conn->sm_pairing_requested = 1;
|
if (have_ltk){
|
||||||
sm_conn->sm_engine_state = SM_INITIATOR_PH4_HAS_LTK;
|
sm_conn->sm_pairing_requested = 1;
|
||||||
sm_reencryption_started(sm_conn);
|
sm_conn->sm_engine_state = SM_INITIATOR_PH4_HAS_LTK;
|
||||||
break;
|
sm_reencryption_started(sm_conn);
|
||||||
}
|
break;
|
||||||
/* fall through */
|
}
|
||||||
|
/* fall through */
|
||||||
|
|
||||||
case IRK_LOOKUP_FAILED:
|
case IRK_LOOKUP_FAILED:
|
||||||
sm_conn->sm_engine_state = SM_INITIATOR_PH1_W2_SEND_PAIRING_REQUEST;
|
sm_conn->sm_engine_state = SM_INITIATOR_PH1_W2_SEND_PAIRING_REQUEST;
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
log_info("irk lookup pending");
|
log_info("irk lookup pending");
|
||||||
sm_conn->sm_pairing_requested = 1;
|
sm_conn->sm_pairing_requested = 1;
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
} else if (sm_conn->sm_engine_state == SM_GENERAL_IDLE){
|
break;
|
||||||
sm_conn->sm_pairing_requested = 1;
|
case SM_GENERAL_IDLE:
|
||||||
|
sm_conn->sm_pairing_requested = 1;
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
sm_trigger_run();
|
sm_trigger_run();
|
||||||
|
Loading…
x
Reference in New Issue
Block a user