port_api.h 26 KB

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