1
0
mirror of https://github.com/bluekitchen/btstack.git synced 2025-03-25 16:43:28 +00:00

l2cap: unify events for can send now, packet sent, channel closed (CbM/ECBM using existing events)

This commit is contained in:
Matthias Ringwald 2021-11-22 14:42:42 +01:00
parent 372dd7ce8a
commit 01f33f4af1
9 changed files with 422 additions and 518 deletions

@ -17,6 +17,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- GAP: gap_set_page_timeout to set Page Timeout
- GAP: gap_inquiry_set_scan_activity to set Inquiry Scan Activity
- L2CAP: emit L2CAP_EVENT_INFORMATION_RESPONSE event with extended features and fixed channels supported
- L2CAP: support Enhanced Credit-based Flow-Control Mode for connection-oriented channels
- POSIX: btstack_signal allows to register for callback on signal, e.g. ctrl-c
- Windows: btstack_stdin_window_register_ctrl_c_callback allows to register for ctrl-c
- A2DP: allow to register media codec validator for sink and source with:
@ -51,6 +52,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.
- L2CAP: drop reason parameter in l2cap_disconnect
- L2CAP: use official terminology for L2CAP channel modes - ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE replaces ENABLE_LE_DATA_CHANNELS
- L2CAP: unify API for can send now, request to send, and send packet and disconnect channel
- L2CAP: unify events for can send now, packet sent, channel closed (CbM/ECBM using existing events)
- RFCOMM: `RFCOMM_EVENT_PORT_CONFIGURATION` contains rfcomm_cid and remote flag, emitted for query config
- RFCOMM: provide status instead of undocumented int error code and bool for API functions
- RFCOMM: remote port configuration, line status, and modem status are sent by channel state machine

@ -282,12 +282,12 @@ static void packet_handler(uint8_t packet_type, uint16_t channel, uint8_t *packe
break;
#ifdef TEST_STREAM_DATA
case L2CAP_EVENT_CBM_CAN_SEND_NOW:
case L2CAP_EVENT_CAN_SEND_NOW:
streamer();
break;
#endif
case L2CAP_EVENT_CBM_CHANNEL_CLOSED:
case L2CAP_EVENT_CHANNEL_CLOSED:
cid = l2cap_event_le_channel_closed_get_local_cid(packet);
printf("L2CAP: Channel closed 0x%02x\n", cid);
break;

@ -254,7 +254,7 @@ static void packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *pack
}
break;
case L2CAP_EVENT_CBM_CHANNEL_CLOSED:
case L2CAP_EVENT_CHANNEL_CLOSED:
printf("L2CAP: Channel closed\n");
le_cbm_connection.cid = 0;
break;

@ -842,12 +842,32 @@ typedef uint8_t sm_key_t[16];
*/
#define L2CAP_EVENT_CONNECTION_PARAMETER_UPDATE_RESPONSE 0x77
/*
* @format H22
* @param con_handle
* @param extended_feature_mask
* @param fixed_channels_supported
*/
#define L2CAP_EVENT_INFORMATION_RESPONSE 0x78
/**
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_CAN_SEND_NOW 0x78
/*
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_PACKET_SENT 0x7a
/*
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_ERTM_BUFFER_RELEASED 0x7b
// L2CAP Channel in LE Credit-based Flow-Control Mode (CBM)
/**
@ -860,7 +880,7 @@ typedef uint8_t sm_key_t[16];
* @param remote_cid
* @param remote_mtu
*/
#define L2CAP_EVENT_CBM_INCOMING_CONNECTION 0x79
#define L2CAP_EVENT_CBM_INCOMING_CONNECTION 0x7c
/**
* @format 11BH122222
@ -875,36 +895,12 @@ typedef uint8_t sm_key_t[16];
* @param local_mtu
* @param remote_mtu
*/
#define L2CAP_EVENT_CBM_CHANNEL_OPENED 0x7a
/*
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_CBM_CHANNEL_CLOSED 0x7b
/*
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_CBM_CAN_SEND_NOW 0x7c
/*
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_CBM_PACKET_SENT 0x7d
/*
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_ERTM_BUFFER_RELEASED 0x7e
#define L2CAP_EVENT_CBM_CHANNEL_OPENED 0x7d
/*
* @format
*/
#define L2CAP_EVENT_TRIGGER_RUN 0x7f
#define L2CAP_EVENT_TRIGGER_RUN 0x7e
/**
* @format 1BH212
@ -915,7 +911,7 @@ typedef uint8_t sm_key_t[16];
* @param num_channels
* @param local_cid first new cid
*/
#define L2CAP_EVENT_ECBM_INCOMING_CONNECTION 0x8A
#define L2CAP_EVENT_ECBM_INCOMING_CONNECTION 0x7f
/**
* @format 11BH122222
@ -930,25 +926,7 @@ typedef uint8_t sm_key_t[16];
* @param local_mtu
* @param remote_mtu
*/
#define L2CAP_EVENT_ECBM_CHANNEL_OPENED 0x8b
/*
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_ECBM_CHANNEL_CLOSED 0x8c
/*
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_ECBM_CAN_SEND_NOW 0x8d
/*
* @format 2
* @param local_cid
*/
#define L2CAP_EVENT_ECBM_PACKET_SENT 0x8e
#define L2CAP_EVENT_ECBM_CHANNEL_OPENED 0x84
/*
* @format 222
@ -956,22 +934,14 @@ typedef uint8_t sm_key_t[16];
* @param mtu
* @param mps
*/
#define L2CAP_EVENT_ECBM_RECONFIGURED 0x8f
#define L2CAP_EVENT_ECBM_RECONFIGURED 0x85
/*
* @format 22
* @param local_cid
* @param reconfigure_result
*/
#define L2CAP_EVENT_ECBM_RECONFIGURATION_COMPLETE 0x96
/*
* @format H22
* @param con_handle
* @param extended_feature_mask
* @param fixed_channels_supported
*/
#define L2CAP_EVENT_INFORMATION_RESPONSE 0x97
#define L2CAP_EVENT_ECBM_RECONFIGURATION_COMPLETE 0x86
// RFCOMM EVENTS

@ -1413,435 +1413,6 @@ static inline uint16_t l2cap_event_connection_parameter_update_response_get_resu
return little_endian_read_16(event, 4);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_CAN_SEND_NOW
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_can_send_now_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field address_type from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return address_type
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_le_incoming_connection_get_address_type(const uint8_t * event){
return event[2];
}
/**
* @brief Get field address from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @param Pointer to storage for address
* @note: btstack_type B
*/
static inline void l2cap_event_le_incoming_connection_get_address(const uint8_t * event, bd_addr_t address){
reverse_bytes(&event[3], address, 6);
}
/**
* @brief Get field handle from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return handle
* @note: btstack_type H
*/
static inline hci_con_handle_t l2cap_event_le_incoming_connection_get_handle(const uint8_t * event){
return little_endian_read_16(event, 9);
}
/**
* @brief Get field psm from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return psm
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_incoming_connection_get_psm(const uint8_t * event){
return little_endian_read_16(event, 11);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_incoming_connection_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 13);
}
/**
* @brief Get field remote_cid from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return remote_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_incoming_connection_get_remote_cid(const uint8_t * event){
return little_endian_read_16(event, 15);
}
/**
* @brief Get field remote_mtu from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return remote_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_incoming_connection_get_remote_mtu(const uint8_t * event){
return little_endian_read_16(event, 17);
}
/**
* @brief Get field status from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return status
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_le_channel_opened_get_status(const uint8_t * event){
return event[2];
}
/**
* @brief Get field address_type from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return address_type
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_le_channel_opened_get_address_type(const uint8_t * event){
return event[3];
}
/**
* @brief Get field address from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @param Pointer to storage for address
* @note: btstack_type B
*/
static inline void l2cap_event_le_channel_opened_get_address(const uint8_t * event, bd_addr_t address){
reverse_bytes(&event[4], address, 6);
}
/**
* @brief Get field handle from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return handle
* @note: btstack_type H
*/
static inline hci_con_handle_t l2cap_event_le_channel_opened_get_handle(const uint8_t * event){
return little_endian_read_16(event, 10);
}
/**
* @brief Get field incoming from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return incoming
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_le_channel_opened_get_incoming(const uint8_t * event){
return event[12];
}
/**
* @brief Get field psm from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return psm
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_channel_opened_get_psm(const uint8_t * event){
return little_endian_read_16(event, 13);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_channel_opened_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 15);
}
/**
* @brief Get field remote_cid from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return remote_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_channel_opened_get_remote_cid(const uint8_t * event){
return little_endian_read_16(event, 17);
}
/**
* @brief Get field local_mtu from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return local_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_channel_opened_get_local_mtu(const uint8_t * event){
return little_endian_read_16(event, 19);
}
/**
* @brief Get field remote_mtu from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return remote_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_channel_opened_get_remote_mtu(const uint8_t * event){
return little_endian_read_16(event, 21);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_CBM_CHANNEL_CLOSED
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_channel_closed_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_CBM_CAN_SEND_NOW
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_can_send_now_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_CBM_PACKET_SENT
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_le_packet_sent_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ERTM_BUFFER_RELEASED
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ertm_buffer_released_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field address_type from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return address_type
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_data_channel_incoming_get_address_type(const uint8_t * event){
return event[2];
}
/**
* @brief Get field address from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @param Pointer to storage for address
* @note: btstack_type B
*/
static inline void l2cap_event_data_channel_incoming_get_address(const uint8_t * event, bd_addr_t address){
reverse_bytes(&event[3], address, 6);
}
/**
* @brief Get field handle from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return handle
* @note: btstack_type H
*/
static inline hci_con_handle_t l2cap_event_data_channel_incoming_get_handle(const uint8_t * event){
return little_endian_read_16(event, 9);
}
/**
* @brief Get field psm from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return psm
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_incoming_get_psm(const uint8_t * event){
return little_endian_read_16(event, 11);
}
/**
* @brief Get field num_channels from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return num_channels
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_data_channel_incoming_get_num_channels(const uint8_t * event){
return event[13];
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_incoming_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 14);
}
/**
* @brief Get field status from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return status
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_data_channel_opened_get_status(const uint8_t * event){
return event[2];
}
/**
* @brief Get field address_type from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return address_type
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_data_channel_opened_get_address_type(const uint8_t * event){
return event[3];
}
/**
* @brief Get field address from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @param Pointer to storage for address
* @note: btstack_type B
*/
static inline void l2cap_event_data_channel_opened_get_address(const uint8_t * event, bd_addr_t address){
reverse_bytes(&event[4], address, 6);
}
/**
* @brief Get field handle from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return handle
* @note: btstack_type H
*/
static inline hci_con_handle_t l2cap_event_data_channel_opened_get_handle(const uint8_t * event){
return little_endian_read_16(event, 10);
}
/**
* @brief Get field incoming from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return incoming
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_data_channel_opened_get_incoming(const uint8_t * event){
return event[12];
}
/**
* @brief Get field psm from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return psm
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_opened_get_psm(const uint8_t * event){
return little_endian_read_16(event, 13);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_opened_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 15);
}
/**
* @brief Get field remote_cid from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return remote_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_opened_get_remote_cid(const uint8_t * event){
return little_endian_read_16(event, 17);
}
/**
* @brief Get field local_mtu from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return local_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_opened_get_local_mtu(const uint8_t * event){
return little_endian_read_16(event, 19);
}
/**
* @brief Get field remote_mtu from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return remote_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_opened_get_remote_mtu(const uint8_t * event){
return little_endian_read_16(event, 21);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_closed_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ECBM_CAN_SEND_NOW
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_can_send_now_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ECBM_PACKET_SENT
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_packet_sent_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field remote_cid from event L2CAP_EVENT_ECBM_RECONFIGURED
* @param event packet
* @return remote_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_reconfigured_get_remote_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field mtu from event L2CAP_EVENT_ECBM_RECONFIGURED
* @param event packet
* @return mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_reconfigured_get_mtu(const uint8_t * event){
return little_endian_read_16(event, 4);
}
/**
* @brief Get field mps from event L2CAP_EVENT_ECBM_RECONFIGURED
* @param event packet
* @return mps
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_reconfigured_get_mps(const uint8_t * event){
return little_endian_read_16(event, 6);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ECBM_RECONFIGURATION_COMPLETE
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_reconfiguration_complete_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field reconfigure_result from event L2CAP_EVENT_ECBM_RECONFIGURATION_COMPLETE
* @param event packet
* @return reconfigure_result
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_data_channel_reconfiguration_complete_get_reconfigure_result(const uint8_t * event){
return little_endian_read_16(event, 4);
}
/**
* @brief Get field con_handle from event L2CAP_EVENT_INFORMATION_RESPONSE
* @param event packet
@ -1870,6 +1441,385 @@ static inline uint16_t l2cap_event_information_response_get_fixed_channels_suppo
return little_endian_read_16(event, 6);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_CAN_SEND_NOW
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_can_send_now_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_PACKET_SENT
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_packet_sent_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ERTM_BUFFER_RELEASED
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ertm_buffer_released_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field address_type from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return address_type
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_cbm_incoming_connection_get_address_type(const uint8_t * event){
return event[2];
}
/**
* @brief Get field address from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @param Pointer to storage for address
* @note: btstack_type B
*/
static inline void l2cap_event_cbm_incoming_connection_get_address(const uint8_t * event, bd_addr_t address){
reverse_bytes(&event[3], address, 6);
}
/**
* @brief Get field handle from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return handle
* @note: btstack_type H
*/
static inline hci_con_handle_t l2cap_event_cbm_incoming_connection_get_handle(const uint8_t * event){
return little_endian_read_16(event, 9);
}
/**
* @brief Get field psm from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return psm
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_cbm_incoming_connection_get_psm(const uint8_t * event){
return little_endian_read_16(event, 11);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_cbm_incoming_connection_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 13);
}
/**
* @brief Get field remote_cid from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return remote_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_cbm_incoming_connection_get_remote_cid(const uint8_t * event){
return little_endian_read_16(event, 15);
}
/**
* @brief Get field remote_mtu from event L2CAP_EVENT_CBM_INCOMING_CONNECTION
* @param event packet
* @return remote_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_cbm_incoming_connection_get_remote_mtu(const uint8_t * event){
return little_endian_read_16(event, 17);
}
/**
* @brief Get field status from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return status
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_cbm_channel_opened_get_status(const uint8_t * event){
return event[2];
}
/**
* @brief Get field address_type from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return address_type
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_cbm_channel_opened_get_address_type(const uint8_t * event){
return event[3];
}
/**
* @brief Get field address from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @param Pointer to storage for address
* @note: btstack_type B
*/
static inline void l2cap_event_cbm_channel_opened_get_address(const uint8_t * event, bd_addr_t address){
reverse_bytes(&event[4], address, 6);
}
/**
* @brief Get field handle from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return handle
* @note: btstack_type H
*/
static inline hci_con_handle_t l2cap_event_cbm_channel_opened_get_handle(const uint8_t * event){
return little_endian_read_16(event, 10);
}
/**
* @brief Get field incoming from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return incoming
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_cbm_channel_opened_get_incoming(const uint8_t * event){
return event[12];
}
/**
* @brief Get field psm from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return psm
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_cbm_channel_opened_get_psm(const uint8_t * event){
return little_endian_read_16(event, 13);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_cbm_channel_opened_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 15);
}
/**
* @brief Get field remote_cid from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return remote_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_cbm_channel_opened_get_remote_cid(const uint8_t * event){
return little_endian_read_16(event, 17);
}
/**
* @brief Get field local_mtu from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return local_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_cbm_channel_opened_get_local_mtu(const uint8_t * event){
return little_endian_read_16(event, 19);
}
/**
* @brief Get field remote_mtu from event L2CAP_EVENT_CBM_CHANNEL_OPENED
* @param event packet
* @return remote_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_cbm_channel_opened_get_remote_mtu(const uint8_t * event){
return little_endian_read_16(event, 21);
}
/**
* @brief Get field address_type from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return address_type
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_ecbm_incoming_connection_get_address_type(const uint8_t * event){
return event[2];
}
/**
* @brief Get field address from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @param Pointer to storage for address
* @note: btstack_type B
*/
static inline void l2cap_event_ecbm_incoming_connection_get_address(const uint8_t * event, bd_addr_t address){
reverse_bytes(&event[3], address, 6);
}
/**
* @brief Get field handle from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return handle
* @note: btstack_type H
*/
static inline hci_con_handle_t l2cap_event_ecbm_incoming_connection_get_handle(const uint8_t * event){
return little_endian_read_16(event, 9);
}
/**
* @brief Get field psm from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return psm
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_incoming_connection_get_psm(const uint8_t * event){
return little_endian_read_16(event, 11);
}
/**
* @brief Get field num_channels from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return num_channels
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_ecbm_incoming_connection_get_num_channels(const uint8_t * event){
return event[13];
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ECBM_INCOMING_CONNECTION
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_incoming_connection_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 14);
}
/**
* @brief Get field status from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return status
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_ecbm_channel_opened_get_status(const uint8_t * event){
return event[2];
}
/**
* @brief Get field address_type from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return address_type
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_ecbm_channel_opened_get_address_type(const uint8_t * event){
return event[3];
}
/**
* @brief Get field address from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @param Pointer to storage for address
* @note: btstack_type B
*/
static inline void l2cap_event_ecbm_channel_opened_get_address(const uint8_t * event, bd_addr_t address){
reverse_bytes(&event[4], address, 6);
}
/**
* @brief Get field handle from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return handle
* @note: btstack_type H
*/
static inline hci_con_handle_t l2cap_event_ecbm_channel_opened_get_handle(const uint8_t * event){
return little_endian_read_16(event, 10);
}
/**
* @brief Get field incoming from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return incoming
* @note: btstack_type 1
*/
static inline uint8_t l2cap_event_ecbm_channel_opened_get_incoming(const uint8_t * event){
return event[12];
}
/**
* @brief Get field psm from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return psm
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_channel_opened_get_psm(const uint8_t * event){
return little_endian_read_16(event, 13);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_channel_opened_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 15);
}
/**
* @brief Get field remote_cid from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return remote_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_channel_opened_get_remote_cid(const uint8_t * event){
return little_endian_read_16(event, 17);
}
/**
* @brief Get field local_mtu from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return local_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_channel_opened_get_local_mtu(const uint8_t * event){
return little_endian_read_16(event, 19);
}
/**
* @brief Get field remote_mtu from event L2CAP_EVENT_ECBM_CHANNEL_OPENED
* @param event packet
* @return remote_mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_channel_opened_get_remote_mtu(const uint8_t * event){
return little_endian_read_16(event, 21);
}
/**
* @brief Get field remote_cid from event L2CAP_EVENT_ECBM_RECONFIGURED
* @param event packet
* @return remote_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_reconfigured_get_remote_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field mtu from event L2CAP_EVENT_ECBM_RECONFIGURED
* @param event packet
* @return mtu
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_reconfigured_get_mtu(const uint8_t * event){
return little_endian_read_16(event, 4);
}
/**
* @brief Get field mps from event L2CAP_EVENT_ECBM_RECONFIGURED
* @param event packet
* @return mps
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_reconfigured_get_mps(const uint8_t * event){
return little_endian_read_16(event, 6);
}
/**
* @brief Get field local_cid from event L2CAP_EVENT_ECBM_RECONFIGURATION_COMPLETE
* @param event packet
* @return local_cid
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_reconfiguration_complete_get_local_cid(const uint8_t * event){
return little_endian_read_16(event, 2);
}
/**
* @brief Get field reconfigure_result from event L2CAP_EVENT_ECBM_RECONFIGURATION_COMPLETE
* @param event packet
* @return reconfigure_result
* @note: btstack_type 2
*/
static inline uint16_t l2cap_event_ecbm_reconfiguration_complete_get_reconfigure_result(const uint8_t * event){
return little_endian_read_16(event, 4);
}
/**
* @brief Get field status from event RFCOMM_EVENT_CHANNEL_OPENED
* @param event packet

@ -168,7 +168,6 @@ static uint8_t l2cap_classic_send(l2cap_channel_t * channel, const uint8_t *data
#endif
#ifdef ENABLE_L2CAP_LE_CREDIT_BASED_FLOW_CONTROL_MODE
static void l2cap_cbm_emit_channel_opened(l2cap_channel_t *channel, uint8_t status);
static void l2cap_cbm_emit_channel_closed(l2cap_channel_t * channel);
static void l2cap_cbm_emit_incoming_connection(l2cap_channel_t *channel);
static void l2cap_credit_based_notify_channel_can_send(l2cap_channel_t *channel);
static void l2cap_cbm_finialize_channel_close(l2cap_channel_t *channel);
@ -2747,7 +2746,7 @@ static void l2cap_handle_hci_le_disconnect_event(l2cap_channel_t * channel){
if (l2cap_send_open_failed_on_hci_disconnect(channel)){
l2cap_cbm_emit_channel_opened(channel, L2CAP_CONNECTION_BASEBAND_DISCONNECT);
} else {
l2cap_cbm_emit_channel_closed(channel);
l2cap_emit_channel_closed(channel);
}
l2cap_free_channel_entry(channel);
}
@ -2894,7 +2893,7 @@ static void l2cap_handle_disconnection_complete(hci_con_handle_t handle){
l2cap_ecbm_emit_reconfigure_complete(channel, 0xffff);
break;
default:
l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_ECBM_CHANNEL_CLOSED);
l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_CHANNEL_CLOSED);
break;
}
l2cap_free_channel_entry(channel);
@ -4837,7 +4836,7 @@ static void l2cap_credit_based_send_pdu(l2cap_channel_t *channel) {
if (done) {
// send done event
l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_CBM_PACKET_SENT);
l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_PACKET_SENT);
// inform about can send now
l2cap_credit_based_notify_channel_can_send(channel);
}
@ -4979,7 +4978,7 @@ static void l2cap_credit_based_notify_channel_can_send(l2cap_channel_t *channel)
if (channel->send_sdu_buffer) return;
channel->waiting_for_can_send_now = 0;
log_debug("le can send now, local_cid 0x%x", channel->local_cid);
l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_CBM_CAN_SEND_NOW);
l2cap_emit_simple_event_with_cid(channel, L2CAP_EVENT_CAN_SEND_NOW);
}
#endif
@ -5022,16 +5021,6 @@ static void l2cap_cbm_emit_channel_opened(l2cap_channel_t *channel, uint8_t stat
hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
l2cap_dispatch_to_channel(channel, HCI_EVENT_PACKET, event, sizeof(event));
}
// 2
static void l2cap_cbm_emit_channel_closed(l2cap_channel_t * channel){
log_info("closed local_cid 0x%x", channel->local_cid);
uint8_t event[4];
event[0] = L2CAP_EVENT_CBM_CHANNEL_CLOSED;
event[1] = sizeof(event) - 2u;
little_endian_store_16(event, 2, channel->local_cid);
hci_dump_packet( HCI_EVENT_PACKET, 0, event, sizeof(event));
l2cap_dispatch_to_channel(channel, HCI_EVENT_PACKET, event, sizeof(event));
}
// finalize closed channel - l2cap_handle_disconnect_request & DISCONNECTION_RESPONSE
void l2cap_cbm_finialize_channel_close(l2cap_channel_t * channel){

@ -129,8 +129,8 @@ static void l2cap_channel_packet_handler(uint8_t packet_type, uint16_t channel,
case HCI_EVENT_PACKET:
switch (hci_event_packet_get_type(packet)) {
case L2CAP_EVENT_CBM_INCOMING_CONNECTION:
psm = l2cap_event_le_incoming_connection_get_psm(packet);
cid = l2cap_event_le_incoming_connection_get_local_cid(packet);
psm = l2cap_event_cbm_incoming_connection_get_psm(packet);
cid = l2cap_event_cbm_incoming_connection_get_local_cid(packet);
if (l2cap_channel_accept_incoming){
l2cap_cbm_accept_connection(cid, data_channel_buffer, sizeof(data_channel_buffer), initial_credits);
} else {

@ -226,7 +226,7 @@ static void l2cap_channel_packet_handler(uint8_t packet_type, uint16_t channel,
switch (hci_event_packet_get_type(packet)) {
case L2CAP_EVENT_ECBM_INCOMING_CONNECTION:
printf("L2CAP_EVENT_DATA_CHANNEL_INCOMING\n");
cid = l2cap_event_data_channel_incoming_get_local_cid(packet);
cid = l2cap_event_ecbm_incoming_connection_get_local_cid(packet);
if (l2cap_channel_accept_incoming){
l2cap_ecbm_accept_channels(cid, 2, initial_credits, TEST_PACKET_SIZE, receive_buffers_2, cids);
} else {
@ -235,16 +235,14 @@ static void l2cap_channel_packet_handler(uint8_t packet_type, uint16_t channel,
}
break;
case L2CAP_EVENT_ECBM_CHANNEL_OPENED:
l2cap_cids[num_l2cap_channel_opened] = l2cap_event_data_channel_opened_get_local_cid(packet);
l2cap_cids[num_l2cap_channel_opened] = l2cap_event_ecbm_channel_opened_get_local_cid(packet);
printf("L2CAP_EVENT_DATA_CHANNEL_OPENED - cid 0x%04x\n", l2cap_cids[num_l2cap_channel_opened] );
num_l2cap_channel_opened++;
break;
case L2CAP_EVENT_ECBM_RECONFIGURATION_COMPLETE:
reconfigure_result = l2cap_event_data_channel_reconfiguration_complete_get_reconfigure_result(packet);
reconfigure_result = l2cap_event_ecbm_reconfiguration_complete_get_reconfigure_result(packet);
break;
case L2CAP_EVENT_CHANNEL_CLOSED:
case L2CAP_EVENT_CBM_CHANNEL_CLOSED:
case L2CAP_EVENT_ECBM_CHANNEL_CLOSED:
num_l2cap_channel_closed++;
break;
default:

@ -225,7 +225,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
}
break;
case L2CAP_EVENT_CBM_CAN_SEND_NOW:
case L2CAP_EVENT_CAN_SEND_NOW:
if (todo_send_short){
todo_send_short = 0;
l2cap_send(cid_credit_based, (uint8_t *) data_short, strlen(data_short));
@ -242,12 +242,7 @@ static void app_packet_handler (uint8_t packet_type, uint16_t channel, uint8_t *
}
break;
case L2CAP_EVENT_CBM_CHANNEL_CLOSED:
cid = l2cap_event_le_channel_closed_get_local_cid(packet);
printf("L2CAP: LE Data Channel closed 0x%02x\n", cid);
break;
case L2CAP_EVENT_CBM_PACKET_SENT:
case L2CAP_EVENT_PACKET_SENT:
cid = l2cap_event_le_packet_sent_get_local_cid(packet);
printf("L2CAP: LE Data Channel Packet sent0x%02x\n", cid);
break;