mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-03-29 22:20:37 +00:00
l2cap: wrap l2cap_emit_opened by l2cap_report_channel_open_failed on error
This commit is contained in:
parent
7f1690cf27
commit
624873c3b8
14
src/l2cap.c
14
src/l2cap.c
@ -963,6 +963,10 @@ static l2cap_fixed_channel_t * l2cap_channel_item_by_cid(uint16_t cid){
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static void l2cap_report_channel_open_failed(l2cap_channel_t * channel, uint8_t status){
|
||||
l2cap_emit_channel_opened(channel, status);
|
||||
}
|
||||
|
||||
// used for fixed channels in LE (ATT/SM) and Classic (Connectionless Channel). CID < 0x04
|
||||
static l2cap_fixed_channel_t * l2cap_fixed_channel_for_channel_id(uint16_t local_cid){
|
||||
if (local_cid >= 0x40) return NULL;
|
||||
@ -1066,7 +1070,7 @@ static void l2cap_rtx_timeout(btstack_timer_source_t * ts){
|
||||
// "When terminating the channel, it is not necessary to send a L2CAP_DisconnectReq
|
||||
// and enter WAIT_DISCONNECT state. Channels can be transitioned directly to the CLOSED state."
|
||||
// notify client
|
||||
l2cap_emit_channel_opened(channel, L2CAP_CONNECTION_RESPONSE_RESULT_RTX_TIMEOUT);
|
||||
l2cap_report_channel_open_failed(channel, L2CAP_CONNECTION_RESPONSE_RESULT_RTX_TIMEOUT);
|
||||
|
||||
// discard channel
|
||||
// no need to stop timer here, it is removed from list during timer callback
|
||||
@ -1929,7 +1933,7 @@ static void l2cap_handle_connection_failed_for_addr(bd_addr_t address, uint8_t s
|
||||
if (channel->state == L2CAP_STATE_EMIT_OPEN_FAILED_AND_DISCARD){
|
||||
done = 0;
|
||||
// failure, forward error code
|
||||
l2cap_emit_channel_opened(channel, status);
|
||||
l2cap_report_channel_open_failed(channel, status);
|
||||
// discard channel
|
||||
l2cap_stop_rtx(channel);
|
||||
btstack_linked_list_remove(&l2cap_channels, (btstack_linked_item_t *) channel);
|
||||
@ -2042,7 +2046,7 @@ static int l2cap_send_open_failed_on_hci_disconnect(l2cap_channel_t * channel){
|
||||
#ifdef ENABLE_CLASSIC
|
||||
static void l2cap_handle_hci_disconnect_event(l2cap_channel_t * channel){
|
||||
if (l2cap_send_open_failed_on_hci_disconnect(channel)){
|
||||
l2cap_emit_channel_opened(channel, L2CAP_CONNECTION_BASEBAND_DISCONNECT);
|
||||
l2cap_report_channel_open_failed(channel, L2CAP_CONNECTION_BASEBAND_DISCONNECT);
|
||||
} else {
|
||||
l2cap_emit_channel_closed(channel);
|
||||
}
|
||||
@ -2565,7 +2569,7 @@ static void l2cap_signaling_handler_channel(l2cap_channel_t *channel, uint8_t *c
|
||||
// channel closed
|
||||
channel->state = L2CAP_STATE_CLOSED;
|
||||
// map l2cap connection response result to BTstack status enumeration
|
||||
l2cap_emit_channel_opened(channel, L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL + result);
|
||||
l2cap_report_channel_open_failed(channel, L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL + result);
|
||||
|
||||
// drop link key if security block
|
||||
if (L2CAP_CONNECTION_RESPONSE_RESULT_SUCCESSFUL + result == L2CAP_CONNECTION_RESPONSE_RESULT_REFUSED_SECURITY){
|
||||
@ -2731,7 +2735,7 @@ static void l2cap_signaling_handler_dispatch(hci_con_handle_t handle, uint8_t *
|
||||
// channel closed
|
||||
channel->state = L2CAP_STATE_CLOSED;
|
||||
// map l2cap connection response result to BTstack status enumeration
|
||||
l2cap_emit_channel_opened(channel, L2CAP_CONNECTION_RESPONSE_RESULT_ERTM_NOT_SUPPORTED);
|
||||
l2cap_report_channel_open_failed(channel, L2CAP_CONNECTION_RESPONSE_RESULT_ERTM_NOT_SUPPORTED);
|
||||
// discard channel
|
||||
btstack_linked_list_remove(&l2cap_channels, (btstack_linked_item_t *) channel);
|
||||
btstack_memory_l2cap_channel_free(channel);
|
||||
|
Loading…
x
Reference in New Issue
Block a user