mirror of
https://github.com/bluekitchen/btstack.git
synced 2025-01-26 12:35:25 +00:00
l2cap: send and receive le connection response accept
This commit is contained in:
parent
1b8b8d056f
commit
230174734c
16
src/l2cap.c
16
src/l2cap.c
@ -751,6 +751,12 @@ static void l2cap_run(void){
|
|||||||
channel->local_sig_id = l2cap_next_sig_id();
|
channel->local_sig_id = l2cap_next_sig_id();
|
||||||
l2cap_send_le_signaling_packet( channel->con_handle, LE_CREDIT_BASED_CONNECTION_REQUEST, channel->local_sig_id, channel->psm, channel->local_cid, 23, 23, 1);
|
l2cap_send_le_signaling_packet( channel->con_handle, LE_CREDIT_BASED_CONNECTION_REQUEST, channel->local_sig_id, channel->psm, channel->local_cid, 23, 23, 1);
|
||||||
break;
|
break;
|
||||||
|
case L2CAP_STATE_WILL_SEND_LE_CONNECTION_RESPONSE_ACCEPT:
|
||||||
|
if (!hci_can_send_acl_packet_now(channel->con_handle)) break;
|
||||||
|
// TODO: support larger MPS
|
||||||
|
channel->state = L2CAP_STATE_OPEN;
|
||||||
|
l2cap_send_le_signaling_packet(channel->con_handle, LE_CREDIT_BASED_CONNECTION_RESPONSE, channel->remote_sig_id, channel->remote_cid, channel->local_mtu, 23, channel->credits_incoming, 0);
|
||||||
|
break;
|
||||||
case L2CAP_STATE_WILL_SEND_LE_CONNECTION_RESPONSE_DECLINE:
|
case L2CAP_STATE_WILL_SEND_LE_CONNECTION_RESPONSE_DECLINE:
|
||||||
if (!hci_can_send_acl_packet_now(channel->con_handle)) break;
|
if (!hci_can_send_acl_packet_now(channel->con_handle)) break;
|
||||||
channel->state = L2CAP_STATE_INVALID;
|
channel->state = L2CAP_STATE_INVALID;
|
||||||
@ -1499,7 +1505,7 @@ static int l2cap_le_signaling_handler_dispatch(hci_con_handle_t handle, uint8_t
|
|||||||
btstack_linked_list_iterator_t it;
|
btstack_linked_list_iterator_t it;
|
||||||
|
|
||||||
uint8_t code = command[L2CAP_SIGNALING_COMMAND_CODE_OFFSET];
|
uint8_t code = command[L2CAP_SIGNALING_COMMAND_CODE_OFFSET];
|
||||||
printf("l2cap_le_signaling_handler_dispatch: command 0x%02x, sig id %u\n", code, sig_id);
|
log_info("l2cap_le_signaling_handler_dispatch: command 0x%02x, sig id %u", code, sig_id);
|
||||||
|
|
||||||
switch (code){
|
switch (code){
|
||||||
|
|
||||||
@ -1627,7 +1633,6 @@ static int l2cap_le_signaling_handler_dispatch(hci_con_handle_t handle, uint8_t
|
|||||||
if (a_channel->con_handle != handle) continue;
|
if (a_channel->con_handle != handle) continue;
|
||||||
if (a_channel->local_sig_id != sig_id) continue;
|
if (a_channel->local_sig_id != sig_id) continue;
|
||||||
channel = a_channel;
|
channel = a_channel;
|
||||||
printf("channel %p\n", channel);
|
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
// TODO: send error
|
// TODO: send error
|
||||||
@ -1864,10 +1869,11 @@ uint8_t l2cap_le_accept_connection(uint16_t local_cid, uint8_t * receive_sdu_buf
|
|||||||
return ERROR_CODE_COMMAND_DISALLOWED;
|
return ERROR_CODE_COMMAND_DISALLOWED;
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: set mtu and receive buffer
|
|
||||||
|
|
||||||
// set state accept connection
|
// set state accept connection
|
||||||
channel->state = L2CAP_STATE_WILL_SEND_CONNECTION_RESPONSE_ACCEPT;
|
channel->state = L2CAP_STATE_WILL_SEND_LE_CONNECTION_RESPONSE_ACCEPT;
|
||||||
|
channel->receive_sdu_buffer = receive_sdu_buffer;
|
||||||
|
channel->local_mtu = mtu;
|
||||||
|
channel->credits_incoming = initial_credits;
|
||||||
|
|
||||||
// go
|
// go
|
||||||
l2cap_run();
|
l2cap_run();
|
||||||
|
@ -118,7 +118,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
|
|||||||
|
|
||||||
case L2CAP_EVENT_INCOMING_CONNECTION: {
|
case L2CAP_EVENT_INCOMING_CONNECTION: {
|
||||||
uint16_t l2cap_cid = little_endian_read_16(packet, 12);
|
uint16_t l2cap_cid = little_endian_read_16(packet, 12);
|
||||||
#if 0
|
#if 1
|
||||||
printf("L2CAP Accepting incoming connection request\n");
|
printf("L2CAP Accepting incoming connection request\n");
|
||||||
l2cap_le_accept_connection(l2cap_cid, receive_buffer_X, sizeof(receive_buffer_X), 1);
|
l2cap_le_accept_connection(l2cap_cid, receive_buffer_X, sizeof(receive_buffer_X), 1);
|
||||||
#else
|
#else
|
||||||
|
Loading…
x
Reference in New Issue
Block a user