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