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