Data Structures | |
struct | l2cap_channel_t |
struct | l2cap_ertm_config_t |
struct | l2cap_ertm_rx_packet_state_t |
struct | l2cap_ertm_tx_packet_state_t |
struct | l2cap_service_t |
struct | l2cap_signaling_response |
Macros | |
#define | L2CAP_LE_AUTOMATIC_CREDITS 0xffff |
Typedefs | |
typedef struct l2cap_signaling_response | l2cap_signaling_response_t |
Functions | |
void | l2cap_accept_connection (uint16_t local_cid) |
Accepts incoming L2CAP connection. More... | |
uint8_t | l2cap_accept_ertm_connection (uint16_t local_cid, l2cap_ertm_config_t *ertm_contig, uint8_t *buffer, uint32_t size) |
Accepts incoming L2CAP connection for Enhanced Retransmission Mode. More... | |
int | l2cap_can_send_fixed_channel_packet_now (hci_con_handle_t con_handle, uint16_t channel_id) |
int | l2cap_can_send_packet_now (uint16_t local_cid) |
Check if outgoing buffer is available and that there's space on the Bluetooth module. More... | |
int | l2cap_can_send_prepared_packet_now (uint16_t local_cid) |
uint8_t | l2cap_create_channel (btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm, uint16_t mtu, uint16_t *out_local_cid) |
Creates L2CAP channel to the PSM of a remote device with baseband address. More... | |
uint8_t | l2cap_create_ertm_channel (btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm, l2cap_ertm_config_t *ertm_contig, uint8_t *buffer, uint32_t size, uint16_t *out_local_cid) |
Creates L2CAP channel to the PSM of a remote device with baseband address using Enhanced Retransmission Mode. More... | |
void | l2cap_decline_connection (uint16_t local_cid) |
Deny incoming L2CAP connection. More... | |
void | l2cap_disconnect (uint16_t local_cid, uint8_t reason) |
Disconnects L2CAP channel with given identifier. More... | |
uint8_t | l2cap_ertm_set_busy (uint16_t local_cid) |
ERTM Set channel as busy. More... | |
uint8_t | l2cap_ertm_set_ready (uint16_t local_cid) |
ERTM Set channel as ready. More... | |
uint8_t * | l2cap_get_outgoing_buffer (void) |
Get outgoing buffer and prepare data. More... | |
uint16_t | l2cap_get_remote_mtu_for_local_cid (uint16_t local_cid) |
Queries the maximal transfer unit (MTU) for L2CAP channel with given identifier. More... | |
void | l2cap_init (void) |
Set up L2CAP and register L2CAP with HCI layer. More... | |
uint8_t | l2cap_le_accept_connection (uint16_t local_cid, uint8_t *receive_sdu_buffer, uint16_t mtu, uint16_t initial_credits) |
int | l2cap_le_can_send_now (uint16_t cid) |
Check if packet can be scheduled for transmission. More... | |
uint8_t | l2cap_le_create_channel (btstack_packet_handler_t packet_handler, hci_con_handle_t con_handle, uint16_t psm, uint8_t *receive_sdu_buffer, uint16_t mtu, uint16_t initial_credits, gap_security_level_t security_level, uint16_t *out_local_cid) |
Create LE Data Channel. More... | |
uint8_t | l2cap_le_decline_connection (uint16_t local_cid) |
Deny incoming LE Data Channel connection due to resource constraints. More... | |
uint8_t | l2cap_le_disconnect (uint16_t cid) |
Disconnect from LE Data Channel. More... | |
uint8_t | l2cap_le_provide_credits (uint16_t cid, uint16_t credits) |
Provide credtis for LE Data Channel. More... | |
uint8_t | l2cap_le_register_service (btstack_packet_handler_t packet_handler, uint16_t psm, gap_security_level_t security_level) |
Register L2CAP LE Data Channel service. More... | |
uint8_t | l2cap_le_request_can_send_now_event (uint16_t cid) |
Request emission of L2CAP_EVENT_LE_CAN_SEND_NOW as soon as possible. More... | |
uint8_t | l2cap_le_send_data (uint16_t cid, uint8_t *data, uint16_t size) |
Send data via LE Data Channel. More... | |
uint8_t | l2cap_le_unregister_service (uint16_t psm) |
Unregister L2CAP LE Data Channel service. More... | |
uint16_t | l2cap_max_le_mtu (void) |
Get max MTU for LE connections based on btstack configuration. More... | |
uint16_t | l2cap_max_mtu (void) |
Get max MTU for Classic connections based on btstack configuration. More... | |
void | l2cap_register_fixed_channel (btstack_packet_handler_t packet_handler, uint16_t channel_id) |
void | l2cap_register_packet_handler (void(*handler)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size)) |
Registers packet handler for LE Connection Parameter Update events. More... | |
uint8_t | l2cap_register_service (btstack_packet_handler_t packet_handler, uint16_t psm, uint16_t mtu, gap_security_level_t security_level) |
Registers L2CAP service with given PSM and MTU, and assigns a packet handler. More... | |
void | l2cap_release_packet_buffer (void) |
Release outgoing buffer (only needed if l2cap_send_prepared is not called) More... | |
void | l2cap_request_can_send_fix_channel_now_event (hci_con_handle_t con_handle, uint16_t channel_id) |
void | l2cap_request_can_send_now_event (uint16_t local_cid) |
Request emission of L2CAP_EVENT_CAN_SEND_NOW as soon as possible. More... | |
void | l2cap_require_security_level_2_for_outgoing_sdp (void) |
int | l2cap_reserve_packet_buffer (void) |
Reserve outgoing buffer. More... | |
int | l2cap_send (uint16_t local_cid, uint8_t *data, uint16_t len) |
Sends L2CAP data packet to the channel with given identifier. More... | |
int | l2cap_send_connectionless (hci_con_handle_t con_handle, uint16_t cid, uint8_t *data, uint16_t len) |
int | l2cap_send_echo_request (hci_con_handle_t con_handle, uint8_t *data, uint16_t len) |
int | l2cap_send_prepared (uint16_t local_cid, uint16_t len) |
Send L2CAP packet prepared in outgoing buffer to channel. More... | |
int | l2cap_send_prepared_connectionless (hci_con_handle_t con_handle, uint16_t cid, uint16_t len) |
uint8_t | l2cap_unregister_service (uint16_t psm) |
Unregisters L2CAP service with given PSM. More... | |
#define L2CAP_LE_AUTOMATIC_CREDITS 0xffff |
typedef struct l2cap_signaling_response l2cap_signaling_response_t |
enum L2CAP_STATE |
void l2cap_accept_connection | ( | uint16_t | local_cid | ) |
Accepts incoming L2CAP connection.
uint8_t l2cap_accept_ertm_connection | ( | uint16_t | local_cid, |
l2cap_ertm_config_t * | ertm_contig, | ||
uint8_t * | buffer, | ||
uint32_t | size | ||
) |
Accepts incoming L2CAP connection for Enhanced Retransmission Mode.
local_cid | |
ertm_config | |
buffer | to store reassembled rx packet, out-of-order packets and unacknowledged outgoing packets with their tretransmission timers |
size | of buffer |
int l2cap_can_send_fixed_channel_packet_now | ( | hci_con_handle_t | con_handle, |
uint16_t | channel_id | ||
) |
References hci_can_send_acl_packet_now(), and UNUSED.
Referenced by att_dispatch_client_can_send_now(), att_dispatch_server_can_send_now(), and sm_run().
int l2cap_can_send_packet_now | ( | uint16_t | local_cid | ) |
Check if outgoing buffer is available and that there's space on the Bluetooth module.
int l2cap_can_send_prepared_packet_now | ( | uint16_t | local_cid | ) |
uint8_t l2cap_create_channel | ( | btstack_packet_handler_t | packet_handler, |
bd_addr_t | address, | ||
uint16_t | psm, | ||
uint16_t | mtu, | ||
uint16_t * | out_local_cid | ||
) |
Creates L2CAP channel to the PSM of a remote device with baseband address.
A new baseband connection will be initiated if necessary.
packet_handler | |
address | |
psm | |
mtu | |
local_cid |
uint8_t l2cap_create_ertm_channel | ( | btstack_packet_handler_t | packet_handler, |
bd_addr_t | address, | ||
uint16_t | psm, | ||
l2cap_ertm_config_t * | ertm_contig, | ||
uint8_t * | buffer, | ||
uint32_t | size, | ||
uint16_t * | out_local_cid | ||
) |
Creates L2CAP channel to the PSM of a remote device with baseband address using Enhanced Retransmission Mode.
A new baseband connection will be initiated if necessary.
packet_handler | |
address | |
psm | |
ertm_config | |
buffer | to store reassembled rx packet, out-of-order packets and unacknowledged outgoing packets with their tretransmission timers |
size | of buffer |
local_cid |
void l2cap_decline_connection | ( | uint16_t | local_cid | ) |
Deny incoming L2CAP connection.
void l2cap_disconnect | ( | uint16_t | local_cid, |
uint8_t | reason | ||
) |
Disconnects L2CAP channel with given identifier.
uint8_t l2cap_ertm_set_busy | ( | uint16_t | local_cid | ) |
ERTM Set channel as busy.
local_cid |
uint8_t l2cap_ertm_set_ready | ( | uint16_t | local_cid | ) |
ERTM Set channel as ready.
local_cid |
uint8_t* l2cap_get_outgoing_buffer | ( | void | ) |
Get outgoing buffer and prepare data.
References COMPLETE_L2CAP_HEADER, and hci_get_outgoing_packet_buffer().
Referenced by att_confirmation(), att_exchange_mtu_request(), att_execute_write_request(), att_find_by_type_value_request(), att_find_information_request(), att_prepare_write_request(), att_read_blob_request(), att_read_by_type_or_group_request_for_uuid128(), att_read_by_type_or_group_request_for_uuid16(), att_read_multiple_request(), att_read_request(), att_server_indicate(), att_server_notify(), att_server_process_validated_request(), and att_write_request().
uint16_t l2cap_get_remote_mtu_for_local_cid | ( | uint16_t | local_cid | ) |
Queries the maximal transfer unit (MTU) for L2CAP channel with given identifier.
void l2cap_init | ( | void | ) |
Set up L2CAP and register L2CAP with HCI layer.
References btstack_packet_callback_registration_t::callback, gap_connectable_control(), hci_add_event_handler(), hci_register_acl_packet_handler(), l2cap_acl_handler(), l2cap_hci_event_handler(), NULL, and signaling_responses_pending.
Referenced by le_counter_setup(), le_prov_app_setup(), and tss_app_setup().
uint8_t l2cap_le_accept_connection | ( | uint16_t | local_cid, |
uint8_t * | receive_sdu_buffer, | ||
uint16_t | mtu, | ||
uint16_t | initial_credits | ||
) |
int l2cap_le_can_send_now | ( | uint16_t | cid | ) |
Check if packet can be scheduled for transmission.
local_cid | L2CAP LE Data Channel Identifier |
uint8_t l2cap_le_create_channel | ( | btstack_packet_handler_t | packet_handler, |
hci_con_handle_t | con_handle, | ||
uint16_t | psm, | ||
uint8_t * | receive_sdu_buffer, | ||
uint16_t | mtu, | ||
uint16_t | initial_credits, | ||
gap_security_level_t | security_level, | ||
uint16_t * | out_local_cid | ||
) |
Create LE Data Channel.
packet_handler | Packet handler for this connection |
con_handle | ACL-LE HCI Connction Handle |
psm | Service PSM to connect to |
receive_buffer | buffer used for reassembly of L2CAP LE Information Frames into service data unit (SDU) with given MTU |
receive_buffer_size | buffer size equals MTU |
initial_credits | Number of initial credits provided to peer or L2CAP_LE_AUTOMATIC_CREDITS to enable automatic credits |
security_level | Minimum required security level |
out_local_cid | L2CAP LE Channel Identifier is stored here |
uint8_t l2cap_le_decline_connection | ( | uint16_t | local_cid | ) |
Deny incoming LE Data Channel connection due to resource constraints.
local_cid | L2CAP LE Data Channel Identifier |
uint8_t l2cap_le_disconnect | ( | uint16_t | cid | ) |
Disconnect from LE Data Channel.
local_cid | L2CAP LE Data Channel Identifier |
uint8_t l2cap_le_provide_credits | ( | uint16_t | cid, |
uint16_t | credits | ||
) |
Provide credtis for LE Data Channel.
local_cid | L2CAP LE Data Channel Identifier |
credits | Number additional credits for peer |
uint8_t l2cap_le_register_service | ( | btstack_packet_handler_t | packet_handler, |
uint16_t | psm, | ||
gap_security_level_t | security_level | ||
) |
Register L2CAP LE Data Channel service.
packet_handler | |
psm | |
security_level |
uint8_t l2cap_le_request_can_send_now_event | ( | uint16_t | cid | ) |
Request emission of L2CAP_EVENT_LE_CAN_SEND_NOW as soon as possible.
local_cid | L2CAP LE Data Channel Identifier |
uint8_t l2cap_le_send_data | ( | uint16_t | cid, |
uint8_t * | data, | ||
uint16_t | size | ||
) |
Send data via LE Data Channel.
local_cid | L2CAP LE Data Channel Identifier |
data | data to send |
size | data size |
uint8_t l2cap_le_unregister_service | ( | uint16_t | psm | ) |
Unregister L2CAP LE Data Channel service.
psm |
uint16_t l2cap_max_le_mtu | ( | void | ) |
Get max MTU for LE connections based on btstack configuration.
References l2cap_max_mtu().
Referenced by att_event_packet_handler(), att_exchange_mtu_request(), gatt_client_att_packet_handler(), and peripheral_mtu().
uint16_t l2cap_max_mtu | ( | void | ) |
Get max MTU for Classic connections based on btstack configuration.
References L2CAP_HEADER_SIZE.
Referenced by l2cap_max_le_mtu().
void l2cap_register_fixed_channel | ( | btstack_packet_handler_t | packet_handler, |
uint16_t | channel_id | ||
) |
References l2cap_fixed_channel::callback, and l2cap_fixed_channel_table_index_for_channel_id().
Referenced by att_dispatch_register_client(), att_dispatch_register_server(), and sm_init().
void l2cap_register_packet_handler | ( | void(*)(uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size) | handler | ) |
Registers packet handler for LE Connection Parameter Update events.
References UNUSED.
uint8_t l2cap_register_service | ( | btstack_packet_handler_t | packet_handler, |
uint16_t | psm, | ||
uint16_t | mtu, | ||
gap_security_level_t | security_level | ||
) |
Registers L2CAP service with given PSM and MTU, and assigns a packet handler.
void l2cap_release_packet_buffer | ( | void | ) |
Release outgoing buffer (only needed if l2cap_send_prepared is not called)
References hci_release_packet_buffer().
Referenced by att_server_process_validated_request().
void l2cap_request_can_send_fix_channel_now_event | ( | hci_con_handle_t | con_handle, |
uint16_t | channel_id | ||
) |
void l2cap_request_can_send_now_event | ( | uint16_t | local_cid | ) |
Request emission of L2CAP_EVENT_CAN_SEND_NOW as soon as possible.
local_cid |
void l2cap_require_security_level_2_for_outgoing_sdp | ( | void | ) |
int l2cap_reserve_packet_buffer | ( | void | ) |
Reserve outgoing buffer.
References hci_reserve_packet_buffer().
Referenced by att_confirmation(), att_exchange_mtu_request(), att_execute_write_request(), att_find_by_type_value_request(), att_find_information_request(), att_prepare_write_request(), att_read_blob_request(), att_read_by_type_or_group_request_for_uuid128(), att_read_by_type_or_group_request_for_uuid16(), att_read_multiple_request(), att_read_request(), att_server_indicate(), att_server_notify(), att_server_process_validated_request(), and att_write_request().
int l2cap_send | ( | uint16_t | local_cid, |
uint8_t * | data, | ||
uint16_t | len | ||
) |
Sends L2CAP data packet to the channel with given identifier.
int l2cap_send_connectionless | ( | hci_con_handle_t | con_handle, |
uint16_t | cid, | ||
uint8_t * | data, | ||
uint16_t | len | ||
) |
References BTSTACK_ACL_BUFFERS_FULL, hci_can_send_acl_packet_now(), hci_get_outgoing_packet_buffer(), hci_reserve_packet_buffer(), l2cap_send_prepared_connectionless(), and log_info.
Referenced by sm_run().
int l2cap_send_echo_request | ( | hci_con_handle_t | con_handle, |
uint8_t * | data, | ||
uint16_t | len | ||
) |
int l2cap_send_prepared | ( | uint16_t | local_cid, |
uint16_t | len | ||
) |
Send L2CAP packet prepared in outgoing buffer to channel.
int l2cap_send_prepared_connectionless | ( | hci_con_handle_t | con_handle, |
uint16_t | cid, | ||
uint16_t | len | ||
) |
References BTSTACK_ACL_BUFFERS_FULL, hci_can_send_prepared_acl_packet_now(), hci_get_outgoing_packet_buffer(), hci_is_packet_buffer_reserved(), hci_send_acl_packet_buffer(), l2cap_setup_header(), log_debug, log_error, and log_info.
Referenced by att_confirmation(), att_exchange_mtu_request(), att_execute_write_request(), att_find_by_type_value_request(), att_find_information_request(), att_prepare_write_request(), att_read_blob_request(), att_read_by_type_or_group_request_for_uuid128(), att_read_by_type_or_group_request_for_uuid16(), att_read_multiple_request(), att_read_request(), att_server_indicate(), att_server_notify(), att_server_process_validated_request(), att_write_request(), and l2cap_send_connectionless().
uint8_t l2cap_unregister_service | ( | uint16_t | psm | ) |
Unregisters L2CAP service with given PSM.