hci: fix gap_connect_cancel for gap_connect_with_whitelist

This commit is contained in:
Matthias Ringwald 2022-05-21 15:29:22 +02:00
parent e57898c743
commit 14f2d8f08a
2 changed files with 32 additions and 14 deletions

View File

@ -15,6 +15,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- HFP HF: emit HFP_SUBEVENT_TRANSMIT_DTMF_CODES after sending DTMF command - HFP HF: emit HFP_SUBEVENT_TRANSMIT_DTMF_CODES after sending DTMF command
### Fixed ### Fixed
- GAP: fix gap_connect_cancel for gap_connect_with_whitelist
- L2CAP: Fix accept incoming ERTM connection when Information Request already complete - L2CAP: Fix accept incoming ERTM connection when Information Request already complete
- HFP AG: activate all AG indicators upon service level connection establishment - HFP AG: activate all AG indicators upon service level connection establishment

View File

@ -7113,25 +7113,42 @@ static hci_connection_t * gap_get_outgoing_connection(void){
} }
uint8_t gap_connect_cancel(void){ uint8_t gap_connect_cancel(void){
hci_connection_t * conn = gap_get_outgoing_connection(); hci_connection_t * conn;
if (!conn) return 0; switch (hci_stack->le_connecting_request){
switch (conn->state){ case LE_CONNECTING_IDLE:
case SEND_CREATE_CONNECTION:
// skip sending create connection and emit event instead
hci_stack->le_connecting_request = LE_CONNECTING_IDLE;
hci_emit_le_connection_complete(conn->address_type, conn->address, 0, ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER);
btstack_linked_list_remove(&hci_stack->connections, (btstack_linked_item_t *) conn);
btstack_memory_hci_connection_free( conn );
break; break;
case SENT_CREATE_CONNECTION: case LE_CONNECTING_WHITELIST:
// request to send cancel connection hci_stack->le_connecting_request = LE_CONNECTING_IDLE;
conn->state = SEND_CANCEL_CONNECTION;
hci_run(); hci_run();
break; break;
default: case LE_CONNECTING_DIRECT:
hci_stack->le_connecting_request = LE_CONNECTING_IDLE;
conn = gap_get_outgoing_connection();
if (conn == NULL){
hci_run();
} else {
switch (conn->state){
case SEND_CREATE_CONNECTION:
// skip sending create connection and emit event instead
hci_emit_le_connection_complete(conn->address_type, conn->address, 0, ERROR_CODE_UNKNOWN_CONNECTION_IDENTIFIER);
btstack_linked_list_remove(&hci_stack->connections, (btstack_linked_item_t *) conn);
btstack_memory_hci_connection_free( conn );
break;
case SENT_CREATE_CONNECTION:
// request to send cancel connection
conn->state = SEND_CANCEL_CONNECTION;
hci_run();
break;
default:
break;
}
}
break;
case LE_CONNECTING_CANCEL:
btstack_unreachable();
break; break;
} }
return 0; return ERROR_CODE_SUCCESS;
} }
/** /**