mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-04-02 16:20:31 +00:00
bnep: handle l2cap open for incoming connections properly
This commit is contained in:
parent
9eeb95b810
commit
72956c7420
33
src/bnep.c
33
src/bnep.c
@ -1251,22 +1251,29 @@ static int bnep_hci_event_handler(uint8_t *packet, uint16_t size)
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (channel->state == BNEP_CHANNEL_STATE_CLOSED) {
|
switch (channel->state){
|
||||||
log_info("L2CAP_EVENT_CHANNEL_OPENED: outgoing connection");
|
case BNEP_CHANNEL_STATE_CLOSED:
|
||||||
|
log_info("L2CAP_EVENT_CHANNEL_OPENED: outgoing connection");
|
||||||
|
|
||||||
bnep_channel_start_timer(channel, BNEP_CONNECTION_TIMEOUT_MS);
|
bnep_channel_start_timer(channel, BNEP_CONNECTION_TIMEOUT_MS);
|
||||||
|
|
||||||
/* Assign connection handle and l2cap cid */
|
/* Assign connection handle and l2cap cid */
|
||||||
channel->l2cap_cid = l2cap_cid;
|
channel->l2cap_cid = l2cap_cid;
|
||||||
channel->con_handle = con_handle;
|
channel->con_handle = con_handle;
|
||||||
|
|
||||||
/* Initiate the connection request */
|
/* Initiate the connection request */
|
||||||
channel->state = BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_RESPONSE;
|
channel->state = BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_RESPONSE;
|
||||||
bnep_channel_state_add(channel, BNEP_CHANNEL_STATE_VAR_SND_CONNECTION_REQUEST);
|
bnep_channel_state_add(channel, BNEP_CHANNEL_STATE_VAR_SND_CONNECTION_REQUEST);
|
||||||
channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(READ_BT_16(packet, 17));
|
channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(READ_BT_16(packet, 17));
|
||||||
bnep_run();
|
bnep_run();
|
||||||
} else {
|
break;
|
||||||
log_error("L2CAP_EVENT_CHANNEL_OPENED: Invalid state: %d", channel->state);
|
case BNEP_CHANNEL_STATE_WAIT_FOR_CONNECTION_REQUEST:
|
||||||
|
/* New information: channel mtu */
|
||||||
|
channel->max_frame_size = bnep_max_frame_size_for_l2cap_mtu(READ_BT_16(packet, 17));
|
||||||
|
break;
|
||||||
|
default:
|
||||||
|
log_error("L2CAP_EVENT_CHANNEL_OPENED: Invalid state: %d", channel->state);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
return 1;
|
return 1;
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user