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