btstack/docs/manual/api_l2cap.tex

84 lines
2.9 KiB
TeX
Raw Normal View History

2014-11-06 14:09:12 +00:00
% !TEX root = btstack_gettingstarted.tex
2015-04-09 15:11:48 +00:00
\section{L2CAP API}
2014-11-06 14:09:12 +00:00
\label{appendix:api_l2cap}
$ $
\begin{lstlisting}
2015-04-09 15:11:48 +00:00
/**
* @brief Set up L2CAP and register L2CAP with HCI layer.
*/
2014-11-06 14:09:12 +00:00
void l2cap_init(void);
2015-04-09 15:11:48 +00:00
/**
* @brief Registers a packet handler that handles HCI and general BTstack events.
*/
2014-11-06 14:09:12 +00:00
void l2cap_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size));
2015-04-09 15:11:48 +00:00
/**
* @brief Creates L2CAP channel to the PSM of a remote device with baseband address. A new baseband connection will be initiated if necessary.
*/
2014-11-06 14:09:12 +00:00
void l2cap_create_channel_internal(void * connection, btstack_packet_handler_t packet_handler, bd_addr_t address, uint16_t psm, uint16_t mtu);
2015-04-09 15:11:48 +00:00
/**
* @brief Disconnects L2CAP channel with given identifier.
*/
2014-11-06 14:09:12 +00:00
void l2cap_disconnect_internal(uint16_t local_cid, uint8_t reason);
2015-04-09 15:11:48 +00:00
/**
* @brief Queries the maximal transfer unit (MTU) for L2CAP channel with given identifier.
*/
2014-11-06 14:09:12 +00:00
uint16_t l2cap_get_remote_mtu_for_local_cid(uint16_t local_cid);
2015-04-09 15:11:48 +00:00
/**
* @brief Sends L2CAP data packet to the channel with given identifier.
*/
2014-11-06 14:09:12 +00:00
int l2cap_send_internal(uint16_t local_cid, uint8_t *data, uint16_t len);
2015-04-09 15:11:48 +00:00
/**
* @brief Registers L2CAP service with given PSM and MTU, and assigns a packet handler. On embedded systems, use NULL for connection parameter.
*/
2015-04-09 12:49:03 +00:00
void l2cap_register_service_internal(void *connection, btstack_packet_handler_t packet_handler, uint16_t psm, uint16_t mtu, gap_security_level_t security_level);
2014-11-06 14:09:12 +00:00
2015-04-09 15:11:48 +00:00
/**
* @brief Unregisters L2CAP service with given PSM. On embedded systems, use NULL for connection parameter.
*/
2014-11-06 14:09:12 +00:00
void l2cap_unregister_service_internal(void *connection, uint16_t psm);
2015-04-09 15:11:48 +00:00
/**
* @brief Accepts/Deny incoming L2CAP connection.
*/
2014-11-06 14:09:12 +00:00
void l2cap_accept_connection_internal(uint16_t local_cid);
void l2cap_decline_connection_internal(uint16_t local_cid, uint8_t reason);
2015-04-09 12:49:03 +00:00
2015-04-09 15:11:48 +00:00
/**
* @brief Request LE connection parameter update
*/
2015-04-09 12:49:03 +00:00
int l2cap_le_request_connection_parameter_update(uint16_t handle, uint16_t interval_min, uint16_t interval_max, uint16_t slave_latency, uint16_t timeout_multiplier);
2015-04-09 15:11:48 +00:00
/**
* @brief Non-blocking UART write
*/
2015-04-09 12:49:03 +00:00
int l2cap_can_send_packet_now(uint16_t local_cid);
int l2cap_reserve_packet_buffer(void);
void l2cap_release_packet_buffer(void);
2015-04-09 15:11:48 +00:00
/**
* @brief Get outgoing buffer and prepare data.
*/
2015-04-09 12:49:03 +00:00
uint8_t *l2cap_get_outgoing_buffer(void);
int l2cap_send_prepared(uint16_t local_cid, uint16_t len);
int l2cap_send_prepared_connectionless(uint16_t handle, uint16_t cid, uint16_t len);
2015-04-09 15:11:48 +00:00
/**
* @brief Bluetooth 4.0 - allows to register handler for Attribute Protocol and Security Manager Protocol.
*/
2015-04-09 12:49:03 +00:00
void l2cap_register_fixed_channel(btstack_packet_handler_t packet_handler, uint16_t channel_id);
uint16_t l2cap_max_mtu(void);
uint16_t l2cap_max_le_mtu(void);
int l2cap_send_connectionless(uint16_t handle, uint16_t cid, uint8_t *data, uint16_t len);
2014-11-06 14:09:12 +00:00
\end{lstlisting}
2015-04-09 12:49:03 +00:00
\pagebreak