sm: defer disconnect for dedicated classic bonding

This commit is contained in:
Matthias Ringwald 2023-05-10 16:36:56 +02:00
parent ab0c69a9cf
commit 553c940898

View File

@ -3954,16 +3954,22 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
sm_conn->sm_engine_state = SM_BR_EDR_RESPONDER_W4_PAIRING_REQUEST;
} else if (sm_conn->sm_pairing_requested){
// check if remote supports fixed channels
bool defer = true;
const hci_connection_t * hci_connection = hci_connection_for_handle(con_handle);
if (hci_connection->l2cap_state.information_state == L2CAP_INFORMATION_STATE_DONE){
// check if remote supports SMP over BR/EDR
if ((hci_connection->l2cap_state.fixed_channels_supported & (1 << L2CAP_CID_BR_EDR_SECURITY_MANAGER)) != 0){
sm_conn->sm_engine_state = SM_BR_EDR_INITIATOR_SEND_PAIRING_REQUEST;
} else {
defer = false;
}
} else {
// wait for fixed channel info
sm_conn->sm_engine_state = SM_BR_EDR_INITIATOR_W4_FIXED_CHANNEL_MASK;
}
if (defer){
hci_dedicated_bonding_defer_disconenct(con_handle, true);
}
}
break;
#endif
@ -4045,6 +4051,7 @@ static void sm_event_packet_handler (uint8_t packet_type, uint16_t channel, uint
sm_conn->sm_engine_state = SM_BR_EDR_INITIATOR_SEND_PAIRING_REQUEST;
} else {
sm_conn->sm_engine_state = SM_INITIATOR_CONNECTED;
hci_dedicated_bonding_defer_disconenct(con_handle, false);
}
}
break;
@ -4651,6 +4658,10 @@ static void sm_pdu_handler(uint8_t packet_type, hci_con_handle_t con_handle, uin
#ifdef ENABLE_CROSS_TRANSPORT_KEY_DERIVATION
case SM_BR_EDR_INITIATOR_W4_PAIRING_RESPONSE:
// dedicated bonding complete
hci_dedicated_bonding_defer_disconenct(sm_conn->sm_handle, false);
if (sm_pdu_code != SM_CODE_PAIRING_RESPONSE){
sm_pdu_received_in_wrong_state(sm_conn);
break;