btstack/docs/manual/api_rfcomm.tex

102 lines
3.9 KiB
TeX
Raw Normal View History

2014-11-06 14:09:12 +00:00
% !TEX root = btstack_gettingstarted.tex
2015-04-09 17:11:48 +02:00
\section{RFCOMM API}
2014-11-06 14:09:12 +00:00
\label{appendix:api_rfcomm}
$ $
\begin{lstlisting}
2015-04-09 17:11:48 +02:00
/**
* @brief Set up RFCOMM.
*/
2014-11-06 14:09:12 +00:00
void rfcomm_init(void);
2015-04-09 17:11:48 +02:00
/**
* @brief Set security level required for incoming connections, need to be called before registering services.
*/
2015-04-09 14:49:03 +02:00
void rfcomm_set_required_security_level(gap_security_level_t security_level);
2015-04-09 17:11:48 +02:00
/**
* @brief Register packet handler.
*/
2015-04-09 14:49:03 +02:00
void rfcomm_register_packet_handler(void (*handler)(void * connection, uint8_t packet_type, uint16_t channel, uint8_t *packet, uint16_t size));
2014-11-06 14:09:12 +00:00
2015-04-09 17:11:48 +02:00
/**
* @brief Creates RFCOMM connection (channel) to a given server channel on a remote device with baseband address. A new baseband connection will be initiated if necessary. This channel will automatically provide enough credits to the remote side
*/
2015-04-09 14:49:03 +02:00
void rfcomm_create_channel_internal(void * connection, bd_addr_t addr, uint8_t channel);
2015-04-09 17:11:48 +02:00
/**
* @brief Creates RFCOMM connection (channel) to a given server channel on a remote device with baseband address. new baseband connection will be initiated if necessary. This channel will use explicit credit management. During channel establishment, an initial amount of credits is provided.
*/
2015-04-09 14:49:03 +02:00
void rfcomm_create_channel_with_initial_credits_internal(void * connection, bd_addr_t addr, uint8_t server_channel, uint8_t initial_credits);
2014-11-06 14:09:12 +00:00
2015-04-09 17:11:48 +02:00
/**
* @brief Disconnects RFCOMM channel with given identifier.
*/
2014-11-06 14:09:12 +00:00
void rfcomm_disconnect_internal(uint16_t rfcomm_cid);
2015-04-09 17:11:48 +02:00
/**
* @brief Registers RFCOMM service for a server channel and a maximum frame size, and assigns a packet handler. On embedded systems, use NULL for connection parameter. This channel provides automatically enough credits to the remote side.
*/
2015-04-09 14:49:03 +02:00
void rfcomm_register_service_internal(void * connection, uint8_t channel, uint16_t max_frame_size);
2014-11-06 14:09:12 +00:00
2015-04-09 17:11:48 +02:00
/**
* @brief Registers RFCOMM service for a server channel and a maximum frame size, and assigns a packet handler. On embedded systems, use NULL for connection parameter. This channel will use explicit credit management. During channel establishment, an initial amount of credits is provided.
*/
2015-04-09 14:49:03 +02:00
void rfcomm_register_service_with_initial_credits_internal(void * connection, uint8_t channel, uint16_t max_frame_size, uint8_t initial_credits);
2014-11-06 14:09:12 +00:00
2015-04-09 17:11:48 +02:00
/**
* @brief Unregister RFCOMM service.
*/
2014-11-06 14:09:12 +00:00
void rfcomm_unregister_service_internal(uint8_t service_channel);
2015-04-09 17:11:48 +02:00
/**
* @brief Accepts/Deny incoming RFCOMM connection.
*/
2014-11-06 14:09:12 +00:00
void rfcomm_accept_connection_internal(uint16_t rfcomm_cid);
void rfcomm_decline_connection_internal(uint16_t rfcomm_cid);
2015-04-09 17:11:48 +02:00
/**
* @brief Grant more incoming credits to the remote side for the given RFCOMM channel identifier.
*/
2014-11-06 14:09:12 +00:00
void rfcomm_grant_credits(uint16_t rfcomm_cid, uint8_t credits);
2015-04-09 17:11:48 +02:00
/**
* @brief Checks if RFCOMM can send packet. Returns yes if packet can be sent.
*/
2015-04-09 14:49:03 +02:00
int rfcomm_can_send_packet_now(uint16_t rfcomm_cid);
2015-04-09 17:11:48 +02:00
/**
* @brief Sends RFCOMM data packet to the RFCOMM channel with given identifier.
*/
2015-04-09 14:49:03 +02:00
int rfcomm_send_internal(uint16_t rfcomm_cid, uint8_t *data, uint16_t len);
2015-04-09 17:11:48 +02:00
/**
* @brief Sends Local Line Status, see LINE_STATUS_..
*/
2015-04-09 14:49:03 +02:00
int rfcomm_send_local_line_status(uint16_t rfcomm_cid, uint8_t line_status);
2015-04-09 17:11:48 +02:00
/**
* @brief Send local modem status. see MODEM_STAUS_..
*/
2015-04-09 14:49:03 +02:00
int rfcomm_send_modem_status(uint16_t rfcomm_cid, uint8_t modem_status);
2015-04-09 17:11:48 +02:00
/**
* @brief Configure remote port
*/
2015-04-09 14:49:03 +02:00
int rfcomm_send_port_configuration(uint16_t rfcomm_cid, rpn_baud_t baud_rate, rpn_data_bits_t data_bits, rpn_stop_bits_t stop_bits, rpn_parity_t parity, rpn_flow_control_t flow_control);
2015-04-09 17:11:48 +02:00
/**
* @brief Query remote port
*/
2015-04-09 14:49:03 +02:00
int rfcomm_query_port_configuration(uint16_t rfcomm_cid);
2015-04-09 17:11:48 +02:00
/**
* @brief Allow to create RFCOMM packet in outgoing buffer.
*/
2015-04-09 14:49:03 +02:00
int rfcomm_reserve_packet_buffer(void);
void rfcomm_release_packet_buffer(void);
uint8_t * rfcomm_get_outgoing_buffer(void);
uint16_t rfcomm_get_max_frame_size(uint16_t rfcomm_cid);
int rfcomm_send_prepared(uint16_t rfcomm_cid, uint16_t len);
2014-11-06 14:09:12 +00:00
\end{lstlisting}
2015-04-09 14:49:03 +02:00
\pagebreak