port_api.h 28 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699
  1. /******************************************************************************
  2. *
  3. * Copyright (C) 1999-2012 Broadcom Corporation
  4. *
  5. * Licensed under the Apache License, Version 2.0 (the "License");
  6. * you may not use this file except in compliance with the License.
  7. * You may obtain a copy of the License at:
  8. *
  9. * http://www.apache.org/licenses/LICENSE-2.0
  10. *
  11. * Unless required by applicable law or agreed to in writing, software
  12. * distributed under the License is distributed on an "AS IS" BASIS,
  13. * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
  14. * See the License for the specific language governing permissions and
  15. * limitations under the License.
  16. *
  17. ******************************************************************************/
  18. /******************************************************************************
  19. *
  20. * this file contains the PORT API definitions
  21. *
  22. ******************************************************************************/
  23. #ifndef PORT_API_H
  24. #define PORT_API_H
  25. #include "common/bt_target.h"
  26. #include "common/bt_defs.h"
  27. /*****************************************************************************
  28. ** Constants and Types
  29. *****************************************************************************/
  30. /*
  31. ** Define port settings structure send from the application in the
  32. ** set settings request, or to the application in the set settings indication.
  33. */
  34. typedef struct {
  35. #define PORT_BAUD_RATE_2400 0x00
  36. #define PORT_BAUD_RATE_4800 0x01
  37. #define PORT_BAUD_RATE_7200 0x02
  38. #define PORT_BAUD_RATE_9600 0x03
  39. #define PORT_BAUD_RATE_19200 0x04
  40. #define PORT_BAUD_RATE_38400 0x05
  41. #define PORT_BAUD_RATE_57600 0x06
  42. #define PORT_BAUD_RATE_115200 0x07
  43. #define PORT_BAUD_RATE_230400 0x08
  44. UINT8 baud_rate;
  45. #define PORT_5_BITS 0x00
  46. #define PORT_6_BITS 0x01
  47. #define PORT_7_BITS 0x02
  48. #define PORT_8_BITS 0x03
  49. UINT8 byte_size;
  50. #define PORT_ONESTOPBIT 0x00
  51. #define PORT_ONE5STOPBITS 0x01
  52. UINT8 stop_bits;
  53. #define PORT_PARITY_NO 0x00
  54. #define PORT_PARITY_YES 0x01
  55. UINT8 parity;
  56. #define PORT_ODD_PARITY 0x00
  57. #define PORT_EVEN_PARITY 0x01
  58. #define PORT_MARK_PARITY 0x02
  59. #define PORT_SPACE_PARITY 0x03
  60. UINT8 parity_type;
  61. #define PORT_FC_OFF 0x00
  62. #define PORT_FC_XONXOFF_ON_INPUT 0x01
  63. #define PORT_FC_XONXOFF_ON_OUTPUT 0x02
  64. #define PORT_FC_CTS_ON_INPUT 0x04
  65. #define PORT_FC_CTS_ON_OUTPUT 0x08
  66. #define PORT_FC_DSR_ON_INPUT 0x10
  67. #define PORT_FC_DSR_ON_OUTPUT 0x20
  68. UINT8 fc_type;
  69. UINT8 rx_char1;
  70. #define PORT_XON_DC1 0x11
  71. UINT8 xon_char;
  72. #define PORT_XOFF_DC3 0x13
  73. UINT8 xoff_char;
  74. } tPORT_STATE;
  75. /*
  76. ** Define the callback function prototypes. Parameters are specific
  77. ** to each event and are described bellow
  78. */
  79. typedef int (tPORT_DATA_CALLBACK) (UINT16 port_handle, void *p_data, UINT16 len);
  80. #define DATA_CO_CALLBACK_TYPE_INCOMING 1
  81. #define DATA_CO_CALLBACK_TYPE_OUTGOING_SIZE 2
  82. #define DATA_CO_CALLBACK_TYPE_OUTGOING 3
  83. typedef int (tPORT_DATA_CO_CALLBACK) (UINT16 port_handle, UINT8 *p_buf, UINT16 len, int type);
  84. typedef void (tPORT_CALLBACK) (UINT32 code, UINT16 port_handle);
  85. typedef void (tPORT_MGMT_CALLBACK) (UINT32 code, UINT16 port_handle, void* data);
  86. /**
  87. * Define the server port manage callback function argument
  88. */
  89. typedef struct {
  90. BOOLEAN accept; /* If upper layer accepts the incoming connection */
  91. BOOLEAN ignore_rfc_state; /* If need to ignore rfc state for PORT_CheckConnection */
  92. UINT16 peer_mtu; /* Max MTU that port can send */
  93. } tPORT_MGMT_SR_CALLBACK_ARG;
  94. /**
  95. * Define the client port manage callback function argument
  96. */
  97. typedef struct {
  98. UINT16 peer_mtu; /* Max MTU that port can send */
  99. } tPORT_MGMT_CL_CALLBACK_ARG;
  100. /*
  101. ** Define events that registered application can receive in the callback
  102. */
  103. #define PORT_EV_RXCHAR 0x00000001 /* Any Character received */
  104. #define PORT_EV_RXFLAG 0x00000002 /* Received certain character */
  105. #define PORT_EV_TXEMPTY 0x00000004 /* Transmitt Queue Empty */
  106. #define PORT_EV_CTS 0x00000008 /* CTS changed state */
  107. #define PORT_EV_DSR 0x00000010 /* DSR changed state */
  108. #define PORT_EV_RLSD 0x00000020 /* RLSD changed state */
  109. #define PORT_EV_BREAK 0x00000040 /* BREAK received */
  110. #define PORT_EV_ERR 0x00000080 /* Line status error occurred */
  111. #define PORT_EV_RING 0x00000100 /* Ring signal detected */
  112. #define PORT_EV_CTSS 0x00000400 /* CTS state */
  113. #define PORT_EV_DSRS 0x00000800 /* DSR state */
  114. #define PORT_EV_RLSDS 0x00001000 /* RLSD state */
  115. #define PORT_EV_OVERRUN 0x00002000 /* receiver buffer overrun */
  116. #define PORT_EV_TXCHAR 0x00004000 /* Any character transmitted */
  117. #define PORT_EV_CONNECTED 0x00000200 /* RFCOMM connection established */
  118. #define PORT_EV_CONNECT_ERR 0x00008000 /* Was not able to establish connection */
  119. /* or disconnected */
  120. #define PORT_EV_FC 0x00010000 /* data flow enabled flag changed by remote */
  121. #define PORT_EV_FCS 0x00020000 /* data flow enable status true = enabled */
  122. /*
  123. ** To register for events application should provide bitmask with
  124. ** corresponding bit set
  125. */
  126. #define PORT_MASK_ALL (PORT_EV_RXCHAR | PORT_EV_TXEMPTY | PORT_EV_CTS | \
  127. PORT_EV_DSR | PORT_EV_RLSD | PORT_EV_BREAK | \
  128. PORT_EV_ERR | PORT_EV_RING | PORT_EV_CONNECT_ERR | \
  129. PORT_EV_DSRS | PORT_EV_CTSS | PORT_EV_RLSDS | \
  130. PORT_EV_RXFLAG | PORT_EV_TXCHAR | PORT_EV_OVERRUN | \
  131. PORT_EV_FC | PORT_EV_FCS | PORT_EV_CONNECTED)
  132. /*
  133. ** Define port result codes
  134. */
  135. #define PORT_SUCCESS 0
  136. #define PORT_ERR_BASE 0
  137. #define PORT_UNKNOWN_ERROR (PORT_ERR_BASE + 1)
  138. #define PORT_ALREADY_OPENED (PORT_ERR_BASE + 2)
  139. #define PORT_CMD_PENDING (PORT_ERR_BASE + 3)
  140. #define PORT_APP_NOT_REGISTERED (PORT_ERR_BASE + 4)
  141. #define PORT_NO_MEM (PORT_ERR_BASE + 5)
  142. #define PORT_NO_RESOURCES (PORT_ERR_BASE + 6)
  143. #define PORT_BAD_BD_ADDR (PORT_ERR_BASE + 7)
  144. #define PORT_BAD_HANDLE (PORT_ERR_BASE + 9)
  145. #define PORT_NOT_OPENED (PORT_ERR_BASE + 10)
  146. #define PORT_LINE_ERR (PORT_ERR_BASE + 11)
  147. #define PORT_START_FAILED (PORT_ERR_BASE + 12)
  148. #define PORT_PAR_NEG_FAILED (PORT_ERR_BASE + 13)
  149. #define PORT_PORT_NEG_FAILED (PORT_ERR_BASE + 14)
  150. #define PORT_SEC_FAILED (PORT_ERR_BASE + 15)
  151. #define PORT_PEER_CONNECTION_FAILED (PORT_ERR_BASE + 16)
  152. #define PORT_PEER_FAILED (PORT_ERR_BASE + 17)
  153. #define PORT_PEER_TIMEOUT (PORT_ERR_BASE + 18)
  154. #define PORT_CLOSED (PORT_ERR_BASE + 19)
  155. #define PORT_TX_FULL (PORT_ERR_BASE + 20)
  156. #define PORT_LOCAL_CLOSED (PORT_ERR_BASE + 21)
  157. #define PORT_LOCAL_TIMEOUT (PORT_ERR_BASE + 22)
  158. #define PORT_TX_QUEUE_DISABLED (PORT_ERR_BASE + 23)
  159. #define PORT_PAGE_TIMEOUT (PORT_ERR_BASE + 24)
  160. #define PORT_INVALID_SCN (PORT_ERR_BASE + 25)
  161. #define PORT_ERR_MAX (PORT_ERR_BASE + 26)
  162. /*****************************************************************************
  163. ** External Function Declarations
  164. *****************************************************************************/
  165. #ifdef __cplusplus
  166. extern "C"
  167. {
  168. #endif
  169. /*******************************************************************************
  170. **
  171. ** Function RFCOMM_CreateConnection
  172. **
  173. ** Description RFCOMM_CreateConnection function is used from the application
  174. ** to establish serial port connection to the peer device,
  175. ** or allow RFCOMM to accept a connection from the peer
  176. ** application.
  177. **
  178. ** Parameters: scn - Service Channel Number as registered with
  179. ** the SDP (server) or obtained using SDP from
  180. ** the peer device (client).
  181. ** is_server - TRUE if requesting application is a server
  182. ** mtu - Maximum frame size the application can accept
  183. ** bd_addr - BD_ADDR of the peer (client)
  184. ** mask - specifies events to be enabled. A value
  185. ** of zero disables all events.
  186. ** p_handle - OUT pointer to the handle.
  187. ** p_mgmt_cb - pointer to callback function to receive
  188. ** connection up/down events.
  189. ** Notes:
  190. **
  191. ** Server can call this function with the same scn parameter multiple times if
  192. ** it is ready to accept multiple simulteneous connections.
  193. **
  194. ** DLCI for the connection is (scn * 2 + 1) if client originates connection on
  195. ** existing none initiator multiplexer channel. Otherwise it is (scn * 2).
  196. ** For the server DLCI can be changed later if client will be calling it using
  197. ** (scn * 2 + 1) dlci.
  198. **
  199. *******************************************************************************/
  200. extern int RFCOMM_CreateConnection (UINT16 uuid, UINT8 scn,
  201. BOOLEAN is_server, UINT16 mtu,
  202. BD_ADDR bd_addr, UINT16 *p_handle,
  203. tPORT_MGMT_CALLBACK *p_mgmt_cb);
  204. /*******************************************************************************
  205. **
  206. ** Function RFCOMM_RemoveConnection
  207. **
  208. ** Description This function is called to close the specified connection.
  209. **
  210. ** Parameters: handle - Handle of the port returned in the Open
  211. **
  212. *******************************************************************************/
  213. extern int RFCOMM_RemoveConnection (UINT16 handle);
  214. /*******************************************************************************
  215. **
  216. ** Function RFCOMM_RemoveServer
  217. **
  218. ** Description This function is called to close the server port.
  219. **
  220. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  221. **
  222. *******************************************************************************/
  223. extern int RFCOMM_RemoveServer (UINT16 handle);
  224. /*******************************************************************************
  225. **
  226. ** Function PORT_SetEventCallback
  227. **
  228. ** Description Set event callback the specified connection.
  229. **
  230. ** Parameters: handle - Handle of the port returned in the Open
  231. ** p_callback - address of the callback function which should
  232. ** be called from the RFCOMM when an event
  233. ** specified in the mask occurs.
  234. **
  235. *******************************************************************************/
  236. extern int PORT_SetEventCallback (UINT16 port_handle,
  237. tPORT_CALLBACK *p_port_cb);
  238. /*******************************************************************************
  239. **
  240. ** Function PORT_ClearKeepHandleFlag
  241. **
  242. ** Description This function is called to clear the keep handle flag
  243. ** which will cause not to keep the port handle open when closed
  244. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  245. **
  246. *******************************************************************************/
  247. int PORT_ClearKeepHandleFlag (UINT16 port_handle);
  248. /*******************************************************************************
  249. **
  250. ** Function PORT_SetEventCallback
  251. **
  252. ** Description Set event data callback the specified connection.
  253. **
  254. ** Parameters: handle - Handle of the port returned in the Open
  255. ** p_callback - address of the callback function which should
  256. ** be called from the RFCOMM when a data
  257. ** packet is received.
  258. **
  259. *******************************************************************************/
  260. extern int PORT_SetDataCallback (UINT16 port_handle,
  261. tPORT_DATA_CALLBACK *p_cb);
  262. extern int PORT_SetDataCOCallback (UINT16 port_handle, tPORT_DATA_CO_CALLBACK *p_port_cb);
  263. /*******************************************************************************
  264. **
  265. ** Function PORT_SetEventMask
  266. **
  267. ** Description This function is called to close the specified connection.
  268. **
  269. ** Parameters: handle - Handle of the port returned in the Open
  270. ** mask - specifies events to be enabled. A value
  271. ** of zero disables all events.
  272. **
  273. *******************************************************************************/
  274. extern int PORT_SetEventMask (UINT16 port_handle, UINT32 mask);
  275. /*******************************************************************************
  276. **
  277. ** Function PORT_CheckConnection
  278. **
  279. ** Description This function returns PORT_SUCCESS if connection referenced
  280. ** by handle is up and running
  281. **
  282. ** Parameters: handle - Handle of the port returned in the Open
  283. ** ignore_rfc_state - If need to ignore rfc state
  284. ** bd_addr - OUT bd_addr of the peer
  285. ** p_lcid - OUT L2CAP's LCID
  286. **
  287. *******************************************************************************/
  288. extern int PORT_CheckConnection (UINT16 handle, BOOLEAN ignore_rfc_state, BD_ADDR bd_addr,
  289. UINT16 *p_lcid);
  290. /*******************************************************************************
  291. **
  292. ** Function PORT_IsOpening
  293. **
  294. ** Description This function returns TRUE if there is any RFCOMM connection
  295. ** opening in process.
  296. **
  297. ** Parameters: TRUE if any connection opening is found
  298. ** bd_addr - bd_addr of the peer
  299. **
  300. *******************************************************************************/
  301. extern BOOLEAN PORT_IsOpening (BD_ADDR bd_addr);
  302. /*******************************************************************************
  303. **
  304. ** Function PORT_SetState
  305. **
  306. ** Description This function configures connection according to the
  307. ** specifications in the tPORT_STATE structure.
  308. **
  309. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  310. ** p_settings - Pointer to a tPORT_STATE structure containing
  311. ** configuration information for the connection.
  312. **
  313. *******************************************************************************/
  314. extern int PORT_SetState (UINT16 handle, tPORT_STATE *p_settings);
  315. /*******************************************************************************
  316. **
  317. ** Function PORT_GetRxQueueCnt
  318. **
  319. ** Description This function return number of buffers on the rx queue.
  320. **
  321. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  322. ** p_rx_queue_count - Pointer to return queue count in.
  323. **
  324. *******************************************************************************/
  325. extern int PORT_GetRxQueueCnt (UINT16 handle, UINT16 *p_rx_queue_count);
  326. /*******************************************************************************
  327. **
  328. ** Function PORT_GetState
  329. **
  330. ** Description This function is called to fill tPORT_STATE structure
  331. ** with the current control settings for the port
  332. **
  333. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  334. ** p_settings - Pointer to a tPORT_STATE structure in which
  335. ** configuration information is returned.
  336. **
  337. *******************************************************************************/
  338. extern int PORT_GetState (UINT16 handle, tPORT_STATE *p_settings);
  339. /*******************************************************************************
  340. **
  341. ** Function PORT_Control
  342. **
  343. ** Description This function directs a specified connection to pass control
  344. ** control information to the peer device.
  345. **
  346. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  347. ** signal - specify the function to be passed
  348. **
  349. *******************************************************************************/
  350. #define PORT_SET_DTRDSR 0x01
  351. #define PORT_CLR_DTRDSR 0x02
  352. #define PORT_SET_CTSRTS 0x03
  353. #define PORT_CLR_CTSRTS 0x04
  354. #define PORT_SET_RI 0x05 /* DCE only */
  355. #define PORT_CLR_RI 0x06 /* DCE only */
  356. #define PORT_SET_DCD 0x07 /* DCE only */
  357. #define PORT_CLR_DCD 0x08 /* DCE only */
  358. #define PORT_BREAK 0x09 /* Break event */
  359. extern int PORT_Control (UINT16 handle, UINT8 signal);
  360. /*******************************************************************************
  361. **
  362. ** Function PORT_FlowControl
  363. **
  364. ** Description This function directs a specified connection to pass
  365. ** flow control message to the peer device. Enable flag passed
  366. ** shows if port can accept more data.
  367. **
  368. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  369. ** enable - enables data flow
  370. **
  371. *******************************************************************************/
  372. extern int PORT_FlowControl (UINT16 handle, BOOLEAN enable);
  373. /*******************************************************************************
  374. **
  375. ** Function PORT_FlowControl_GiveCredit
  376. **
  377. ** Description This function gives specified credits to the peer
  378. **
  379. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  380. ** enable - enables data flow
  381. ** credits_given - credits to give
  382. **
  383. *******************************************************************************/
  384. extern int PORT_FlowControl_GiveCredit (UINT16 handle, BOOLEAN enable, UINT16 credits_given);
  385. /*******************************************************************************
  386. **
  387. ** Function PORT_GetModemStatus
  388. **
  389. ** Description This function retrieves modem control signals. Normally
  390. ** application will call this function after a callback
  391. ** function is called with notification that one of signals
  392. ** has been changed.
  393. **
  394. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  395. ** callback.
  396. ** p_signal - specify the pointer to control signals info
  397. **
  398. *******************************************************************************/
  399. #define PORT_DTRDSR_ON 0x01
  400. #define PORT_CTSRTS_ON 0x02
  401. #define PORT_RING_ON 0x04
  402. #define PORT_DCD_ON 0x08
  403. /*
  404. ** Define default initial local modem signals state set after connection established
  405. */
  406. #define PORT_OBEX_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
  407. #define PORT_SPP_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
  408. #define PORT_PPP_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
  409. #define PORT_DUN_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON)
  410. extern int PORT_GetModemStatus (UINT16 handle, UINT8 *p_control_signal);
  411. /*******************************************************************************
  412. **
  413. ** Function PORT_ClearError
  414. **
  415. ** Description This function retreives information about a communications
  416. ** error and reports current status of a connection. The
  417. ** function should be called when an error occures to clear
  418. ** the connection error flag and to enable additional read
  419. ** and write operations.
  420. **
  421. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  422. ** p_errors - pointer of the variable to receive error codes
  423. ** p_status - pointer to the tPORT_STATUS structur to receive
  424. ** connection status
  425. **
  426. *******************************************************************************/
  427. #define PORT_ERR_BREAK 0x01 /* Break condition occured on the peer device */
  428. #define PORT_ERR_OVERRUN 0x02 /* Overrun is reported by peer device */
  429. #define PORT_ERR_FRAME 0x04 /* Framing error reported by peer device */
  430. #define PORT_ERR_RXOVER 0x08 /* Input queue overflow occured */
  431. #define PORT_ERR_TXFULL 0x10 /* Output queue overflow occured */
  432. typedef struct {
  433. #define PORT_FLAG_CTS_HOLD 0x01 /* Tx is waiting for CTS signal */
  434. #define PORT_FLAG_DSR_HOLD 0x02 /* Tx is waiting for DSR signal */
  435. #define PORT_FLAG_RLSD_HOLD 0x04 /* Tx is waiting for RLSD signal */
  436. UINT16 flags;
  437. UINT16 in_queue_size; /* Number of bytes in the input queue */
  438. UINT16 out_queue_size; /* Number of bytes in the output queue */
  439. UINT16 mtu_size; /* peer MTU size */
  440. } tPORT_STATUS;
  441. extern int PORT_ClearError (UINT16 handle, UINT16 *p_errors,
  442. tPORT_STATUS *p_status);
  443. /*******************************************************************************
  444. **
  445. ** Function PORT_SendError
  446. **
  447. ** Description This function send a communications error to the peer device
  448. **
  449. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  450. ** errors - receive error codes
  451. **
  452. *******************************************************************************/
  453. extern int PORT_SendError (UINT16 handle, UINT8 errors);
  454. /*******************************************************************************
  455. **
  456. ** Function PORT_GetQueueStatus
  457. **
  458. ** Description This function reports current status of a connection.
  459. **
  460. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  461. ** p_status - pointer to the tPORT_STATUS structur to receive
  462. ** connection status
  463. **
  464. *******************************************************************************/
  465. extern int PORT_GetQueueStatus (UINT16 handle, tPORT_STATUS *p_status);
  466. /*******************************************************************************
  467. **
  468. ** Function PORT_Purge
  469. **
  470. ** Description This function discards all the data from the output or
  471. ** input queues of the specified connection.
  472. **
  473. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  474. ** purge_flags - specify the action to take.
  475. **
  476. *******************************************************************************/
  477. #define PORT_PURGE_TXCLEAR 0x01
  478. #define PORT_PURGE_RXCLEAR 0x02
  479. extern int PORT_Purge (UINT16 handle, UINT8 purge_flags);
  480. /*******************************************************************************
  481. **
  482. ** Function PORT_Read
  483. **
  484. ** Description This function returns the pointer to the buffer received
  485. ** from the peer device. Normally application will call this
  486. ** function after receiving PORT_EVT_RXCHAR event.
  487. ** Application calling this function is responsible to free
  488. ** buffer returned.
  489. **
  490. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  491. ** callback.
  492. ** pp_buf - pointer to address of buffer with data,
  493. **
  494. *******************************************************************************/
  495. extern int PORT_Read (UINT16 handle, BT_HDR **pp_buf);
  496. /*******************************************************************************
  497. **
  498. ** Function PORT_ReadData
  499. **
  500. ** Description Normally application will call this function after receiving
  501. ** PORT_EVT_RXCHAR event.
  502. **
  503. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  504. ** callback.
  505. ** p_data - Data area
  506. ** max_len - Byte count requested
  507. ** p_len - Byte count received
  508. **
  509. *******************************************************************************/
  510. extern int PORT_ReadData (UINT16 handle, char *p_data, UINT16 max_len,
  511. UINT16 *p_len);
  512. /*******************************************************************************
  513. **
  514. ** Function PORT_Write
  515. **
  516. ** Description This function to send BT buffer to the peer device.
  517. ** Application should not free the buffer.
  518. **
  519. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  520. ** p_buf - pointer to the buffer with data,
  521. **
  522. *******************************************************************************/
  523. extern int PORT_Write (UINT16 handle, BT_HDR *p_buf);
  524. /*******************************************************************************
  525. **
  526. ** Function PORT_WriteData
  527. **
  528. ** Description This function is called from the legacy application to
  529. ** send data.
  530. **
  531. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  532. ** p_data - Data area
  533. ** max_len - Byte count to write
  534. ** p_len - Bytes written
  535. **
  536. *******************************************************************************/
  537. extern int PORT_WriteData (UINT16 handle, char *p_data, UINT16 max_len,
  538. UINT16 *p_len);
  539. /*******************************************************************************
  540. **
  541. ** Function PORT_WriteDataCO
  542. **
  543. ** Description Normally not GKI aware application will call this function
  544. ** to send data to the port by callout functions.
  545. **
  546. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  547. **
  548. *******************************************************************************/
  549. extern int PORT_WriteDataCO (UINT16 handle, int *p_len, int len, UINT8 *p_data);
  550. /*******************************************************************************
  551. **
  552. ** Function PORT_Test
  553. **
  554. ** Description Application can call this function to send RFCOMM Test frame
  555. **
  556. ** Parameters: handle - Handle returned in the RFCOMM_CreateConnection
  557. ** p_data - Data area
  558. ** max_len - Byte count requested
  559. **
  560. *******************************************************************************/
  561. extern int PORT_Test (UINT16 handle, UINT8 *p_data, UINT16 len);
  562. /*******************************************************************************
  563. **
  564. ** Function RFCOMM_Init
  565. **
  566. ** Description This function is called to initialize RFCOMM layer
  567. **
  568. *******************************************************************************/
  569. extern bt_status_t RFCOMM_Init (void);
  570. /*******************************************************************************
  571. **
  572. ** Function RFCOMM_Deinit
  573. **
  574. ** Description This function is called to deinitialize the control block
  575. ** for this layer.
  576. **
  577. ** Returns void
  578. **
  579. *******************************************************************************/
  580. extern void RFCOMM_Deinit(void);
  581. /*******************************************************************************
  582. **
  583. ** Function PORT_SetTraceLevel
  584. **
  585. ** Description This function sets the trace level for RFCOMM. If called with
  586. ** a value of 0xFF, it simply reads the current trace level.
  587. **
  588. ** Returns the new (current) trace level
  589. **
  590. *******************************************************************************/
  591. extern UINT8 PORT_SetTraceLevel (UINT8 new_level);
  592. /*******************************************************************************
  593. **
  594. ** Function PORT_GetResultString
  595. **
  596. ** Description This function returns the human-readable string for a given
  597. ** result code.
  598. **
  599. ** Returns a pointer to the human-readable string for the given
  600. ** result. Note that the string returned must not be freed.
  601. **
  602. *******************************************************************************/
  603. extern const char *PORT_GetResultString (const uint8_t result_code);
  604. #ifdef __cplusplus
  605. }
  606. #endif
  607. #endif /* PORT_API_H */