RFCOMM: Remove dead code

Test: compile
Change-Id: I1a989515f57d68a3ea30ac0f86f7e1196cfcd2b9
diff --git a/system/stack/include/port_api.h b/system/stack/include/port_api.h
index b0a7e63..daea3d4 100644
--- a/system/stack/include/port_api.h
+++ b/system/stack/include/port_api.h
@@ -35,47 +35,27 @@
  * set settings request, or to the application in the set settings indication.
 */
 typedef struct {
-#define PORT_BAUD_RATE_2400 0x00
-#define PORT_BAUD_RATE_4800 0x01
-#define PORT_BAUD_RATE_7200 0x02
 #define PORT_BAUD_RATE_9600 0x03
-#define PORT_BAUD_RATE_19200 0x04
-#define PORT_BAUD_RATE_38400 0x05
-#define PORT_BAUD_RATE_57600 0x06
-#define PORT_BAUD_RATE_115200 0x07
-#define PORT_BAUD_RATE_230400 0x08
 
   uint8_t baud_rate;
 
-#define PORT_5_BITS 0x00
-#define PORT_6_BITS 0x01
-#define PORT_7_BITS 0x02
 #define PORT_8_BITS 0x03
 
   uint8_t byte_size;
 
 #define PORT_ONESTOPBIT 0x00
-#define PORT_ONE5STOPBITS 0x01
   uint8_t stop_bits;
 
 #define PORT_PARITY_NO 0x00
-#define PORT_PARITY_YES 0x01
   uint8_t parity;
 
 #define PORT_ODD_PARITY 0x00
-#define PORT_EVEN_PARITY 0x01
-#define PORT_MARK_PARITY 0x02
-#define PORT_SPACE_PARITY 0x03
 
   uint8_t parity_type;
 
 #define PORT_FC_OFF 0x00
-#define PORT_FC_XONXOFF_ON_INPUT 0x01
-#define PORT_FC_XONXOFF_ON_OUTPUT 0x02
 #define PORT_FC_CTS_ON_INPUT 0x04
 #define PORT_FC_CTS_ON_OUTPUT 0x08
-#define PORT_FC_DSR_ON_INPUT 0x10
-#define PORT_FC_DSR_ON_OUTPUT 0x20
 
   uint8_t fc_type;
 
@@ -133,18 +113,6 @@
 #define PORT_EV_FCS 0x00020000
 
 /*
- * To register for events application should provide bitmask with
- * corresponding bit set
-*/
-
-#define PORT_MASK_ALL                                                  \
-  (PORT_EV_RXCHAR | PORT_EV_TXEMPTY | PORT_EV_CTS | PORT_EV_DSR |      \
-   PORT_EV_RLSD | PORT_EV_BREAK | PORT_EV_ERR | PORT_EV_RING |         \
-   PORT_EV_CONNECT_ERR | PORT_EV_DSRS | PORT_EV_CTSS | PORT_EV_RLSDS | \
-   PORT_EV_RXFLAG | PORT_EV_TXCHAR | PORT_EV_OVERRUN | PORT_EV_FC |    \
-   PORT_EV_FCS | PORT_EV_CONNECTED)
-
-/*
  * Define port result codes
 */
 #define PORT_SUCCESS 0
@@ -267,21 +235,6 @@
  ******************************************************************************/
 int PORT_ClearKeepHandleFlag(uint16_t port_handle);
 
-/*******************************************************************************
- *
- * Function         PORT_SetEventCallback
- *
- * Description      Set event data callback the specified connection.
- *
- * Parameters:      handle       - Handle of the port returned in the Open
- *                  p_callback   - address of the callback function which should
- *                                 be called from the RFCOMM when a data
- *                                 packet is received.
- *
- ******************************************************************************/
-extern int PORT_SetDataCallback(uint16_t port_handle,
-                                tPORT_DATA_CALLBACK* p_cb);
-
 extern int PORT_SetDataCOCallback(uint16_t port_handle,
                                   tPORT_DATA_CO_CALLBACK* p_port_cb);
 /*******************************************************************************
@@ -341,18 +294,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_GetRxQueueCnt
- *
- * Description      This function return number of buffers on the rx queue.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  p_rx_queue_count - Pointer to return queue count in.
- *
- ******************************************************************************/
-extern int PORT_GetRxQueueCnt(uint16_t handle, uint16_t* p_rx_queue_count);
-
-/*******************************************************************************
- *
  * Function         PORT_GetState
  *
  * Description      This function is called to fill tPORT_STATE structure
@@ -367,43 +308,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_Control
- *
- * Description      This function directs a specified connection to pass control
- *                  control information to the peer device.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  signal     - specify the function to be passed
- *
- ******************************************************************************/
-#define PORT_SET_DTRDSR 0x01
-#define PORT_CLR_DTRDSR 0x02
-#define PORT_SET_CTSRTS 0x03
-#define PORT_CLR_CTSRTS 0x04
-#define PORT_SET_RI 0x05  /* DCE only */
-#define PORT_CLR_RI 0x06  /* DCE only */
-#define PORT_SET_DCD 0x07 /* DCE only */
-#define PORT_CLR_DCD 0x08 /* DCE only */
-#define PORT_BREAK 0x09   /* Break event */
-
-extern int PORT_Control(uint16_t handle, uint8_t signal);
-
-/*******************************************************************************
- *
- * Function         PORT_FlowControl
- *
- * Description      This function directs a specified connection to pass
- *                  flow control message to the peer device.  Enable flag passed
- *                  shows if port can accept more data.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  enable     - enables data flow
- *
- ******************************************************************************/
-extern int PORT_FlowControl(uint16_t handle, bool enable);
-
-/*******************************************************************************
- *
  * Function         PORT_FlowControl_MaxCredit
  *
  * Description      This function directs a specified connection to pass
@@ -417,20 +321,6 @@
  ******************************************************************************/
 extern int PORT_FlowControl_MaxCredit(uint16_t handle, bool enable);
 
-/*******************************************************************************
- *
- * Function         PORT_GetModemStatus
- *
- * Description      This function retrieves modem control signals.  Normally
- *                  application will call this function after a callback
- *                  function is called with notification that one of signals
- *                  has been changed.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                               callback.
- *                  p_signal   - specify the pointer to control signals info
- *
- ******************************************************************************/
 #define PORT_DTRDSR_ON 0x01
 #define PORT_CTSRTS_ON 0x02
 #define PORT_RING_ON 0x04
@@ -447,103 +337,12 @@
   (PORT_DTRDSR_ON | PORT_CTSRTS_ON | PORT_DCD_ON)
 #define PORT_DUN_DEFAULT_SIGNAL_STATE (PORT_DTRDSR_ON | PORT_CTSRTS_ON)
 
-extern int PORT_GetModemStatus(uint16_t handle, uint8_t* p_control_signal);
-
-/*******************************************************************************
- *
- * Function         PORT_ClearError
- *
- * Description      This function retreives information about a communications
- *                  error and reports current status of a connection.  The
- *                  function should be called when an error occures to clear
- *                  the connection error flag and to enable additional read
- *                  and write operations.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  p_errors   - pointer of the variable to receive error codes
- *                  p_status   - pointer to the tPORT_STATUS structur to receive
- *                               connection status
- *
- ******************************************************************************/
-
 #define PORT_ERR_BREAK 0x01   /* Break condition occured on the peer device */
 #define PORT_ERR_OVERRUN 0x02 /* Overrun is reported by peer device */
 #define PORT_ERR_FRAME 0x04   /* Framing error reported by peer device */
 #define PORT_ERR_RXOVER 0x08  /* Input queue overflow occured */
 #define PORT_ERR_TXFULL 0x10  /* Output queue overflow occured */
 
-typedef struct {
-#define PORT_FLAG_CTS_HOLD 0x01  /* Tx is waiting for CTS signal */
-#define PORT_FLAG_DSR_HOLD 0x02  /* Tx is waiting for DSR signal */
-#define PORT_FLAG_RLSD_HOLD 0x04 /* Tx is waiting for RLSD signal */
-
-  uint16_t flags;
-  uint16_t in_queue_size;  /* Number of bytes in the input queue */
-  uint16_t out_queue_size; /* Number of bytes in the output queue */
-  uint16_t mtu_size;       /* peer MTU size */
-} tPORT_STATUS;
-
-extern int PORT_ClearError(uint16_t handle, uint16_t* p_errors,
-                           tPORT_STATUS* p_status);
-
-/*******************************************************************************
- *
- * Function         PORT_SendError
- *
- * Description      This function send a communications error to the peer device
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  errors     - receive error codes
- *
- ******************************************************************************/
-extern int PORT_SendError(uint16_t handle, uint8_t errors);
-
-/*******************************************************************************
- *
- * Function         PORT_GetQueueStatus
- *
- * Description      This function reports current status of a connection.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  p_status   - pointer to the tPORT_STATUS structur to receive
- *                               connection status
- *
- ******************************************************************************/
-extern int PORT_GetQueueStatus(uint16_t handle, tPORT_STATUS* p_status);
-
-/*******************************************************************************
- *
- * Function         PORT_Purge
- *
- * Description      This function discards all the data from the output or
- *                  input queues of the specified connection.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  purge_flags - specify the action to take.
- *
- ******************************************************************************/
-#define PORT_PURGE_TXCLEAR 0x01
-#define PORT_PURGE_RXCLEAR 0x02
-
-extern int PORT_Purge(uint16_t handle, uint8_t purge_flags);
-
-/*******************************************************************************
- *
- * Function         PORT_Read
- *
- * Description      This function returns the pointer to the buffer received
- *                  from the peer device.  Normally application will call this
- *                  function after receiving PORT_EVT_RXCHAR event.
- *                  Application calling this function is responsible to free
- *                  buffer returned.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                                callback.
- *                  pp_buf      - pointer to address of buffer with data,
- *
- ******************************************************************************/
-extern int PORT_Read(uint16_t handle, BT_HDR** pp_buf);
-
 /*******************************************************************************
  *
  * Function         PORT_ReadData
@@ -563,19 +362,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_Write
- *
- * Description      This function to send BT buffer to the peer device.
- *                  Application should not free the buffer.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  p_buf       - pointer to the buffer with data,
- *
- ******************************************************************************/
-extern int PORT_Write(uint16_t handle, BT_HDR* p_buf);
-
-/*******************************************************************************
- *
  * Function         PORT_WriteData
  *
  * Description      This function is called from the legacy application to
@@ -604,19 +390,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_Test
- *
- * Description      Application can call this function to send RFCOMM Test frame
- *
- * Parameters:      handle      - Handle returned in the RFCOMM_CreateConnection
- *                  p_data      - Data area
- *                  max_len     - Byte count requested
- *
- ******************************************************************************/
-extern int PORT_Test(uint16_t handle, uint8_t* p_data, uint16_t len);
-
-/*******************************************************************************
- *
  * Function         RFCOMM_Init
  *
  * Description      This function is called to initialize RFCOMM layer
diff --git a/system/stack/rfcomm/port_api.cc b/system/stack/rfcomm/port_api.cc
index 0bb817d..f2b9583 100644
--- a/system/stack/rfcomm/port_api.cc
+++ b/system/stack/rfcomm/port_api.cc
@@ -31,8 +31,6 @@
 #include "osi/include/mutex.h"
 
 #include "bt_common.h"
-#include "btm_api.h"
-#include "btm_int.h"
 #include "l2c_api.h"
 #include "port_api.h"
 #include "port_int.h"
@@ -40,17 +38,8 @@
 #include "rfcdefs.h"
 #include "sdp_api.h"
 
-/* duration of break in 200ms units */
-#define PORT_BREAK_DURATION 1
-
-#define info(fmt, ...) LOG_INFO(LOG_TAG, "%s: " fmt, __func__, ##__VA_ARGS__)
-#define debug(fmt, ...) LOG_DEBUG(LOG_TAG, "%s: " fmt, __func__, ##__VA_ARGS__)
 #define error(fmt, ...) \
   LOG_ERROR(LOG_TAG, "## ERROR : %s: " fmt "##", __func__, ##__VA_ARGS__)
-#define asrt(s)                                                            \
-  if (!(s))                                                                \
-  LOG_ERROR(LOG_TAG, "## %s assert %s failed at line:%d ##", __func__, #s, \
-            __LINE__)
 
 /* Mapping from PORT_* result codes to human readable strings. */
 static const char* result_code_strings[] = {"Success",
@@ -368,40 +357,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_SetDataCallback
- *
- * Description      This function is when a data packet is received
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  p_callback - address of the callback function which should
- *                               be called from the RFCOMM when data packet
- *                               is received.
- *
- *
- ******************************************************************************/
-int PORT_SetDataCallback(uint16_t port_handle, tPORT_DATA_CALLBACK* p_port_cb) {
-  tPORT* p_port;
-
-  RFCOMM_TRACE_API("PORT_SetDataCallback() handle:%d cb 0x%x", port_handle,
-                   p_port_cb);
-
-  /* Check if handle is valid to avoid crashing */
-  if ((port_handle == 0) || (port_handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[port_handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  p_port->p_data_callback = p_port_cb;
-
-  return (PORT_SUCCESS);
-}
-/*******************************************************************************
- *
  * Function         PORT_SetCODataCallback
  *
  * Description      This function is when a data packet is received
@@ -602,45 +557,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_GetRxQueueCnt
- *
- * Description      This function return number of buffers on the rx queue.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  p_rx_queue_count - Pointer to return queue count in.
- *
- ******************************************************************************/
-int PORT_GetRxQueueCnt(uint16_t handle, uint16_t* p_rx_queue_count) {
-  tPORT* p_port;
-
-  RFCOMM_TRACE_API("PORT_GetRxQueueCnt() handle:%d", handle);
-
-  /* Check if handle is valid to avoid crashing */
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  if (p_port->line_status) {
-    return (PORT_LINE_ERR);
-  }
-
-  *p_rx_queue_count = p_port->rx.queue_size;
-
-  RFCOMM_TRACE_API(
-      "PORT_GetRxQueueCnt() p_rx_queue_count:%d, p_port->rx.queue.count = %d",
-      *p_rx_queue_count, p_port->rx.queue_size);
-
-  return (PORT_SUCCESS);
-}
-
-/*******************************************************************************
- *
  * Function         PORT_GetState
  *
  * Description      This function is called to fill tPORT_STATE structure
@@ -677,153 +593,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_Control
- *
- * Description      This function directs a specified connection to pass control
- *                  control information to the peer device.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  signal     = specify the function to be passed
- *
- ******************************************************************************/
-int PORT_Control(uint16_t handle, uint8_t signal) {
-  tPORT* p_port;
-  uint8_t old_modem_signal;
-
-  RFCOMM_TRACE_API("PORT_Control() handle:%d signal:0x%x", handle, signal);
-
-  /* Check if handle is valid to avoid crashing */
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  old_modem_signal = p_port->local_ctrl.modem_signal;
-  p_port->local_ctrl.break_signal = 0;
-
-  switch (signal) {
-    case PORT_SET_CTSRTS:
-      p_port->local_ctrl.modem_signal |= PORT_CTSRTS_ON;
-      break;
-
-    case PORT_CLR_CTSRTS:
-      p_port->local_ctrl.modem_signal &= ~PORT_CTSRTS_ON;
-      break;
-
-    case PORT_SET_DTRDSR:
-      p_port->local_ctrl.modem_signal |= PORT_DTRDSR_ON;
-      break;
-
-    case PORT_CLR_DTRDSR:
-      p_port->local_ctrl.modem_signal &= ~PORT_DTRDSR_ON;
-      break;
-
-    case PORT_SET_RI:
-      p_port->local_ctrl.modem_signal |= PORT_RING_ON;
-      break;
-
-    case PORT_CLR_RI:
-      p_port->local_ctrl.modem_signal &= ~PORT_RING_ON;
-      break;
-
-    case PORT_SET_DCD:
-      p_port->local_ctrl.modem_signal |= PORT_DCD_ON;
-      break;
-
-    case PORT_CLR_DCD:
-      p_port->local_ctrl.modem_signal &= ~PORT_DCD_ON;
-      break;
-  }
-
-  if (signal == PORT_BREAK)
-    p_port->local_ctrl.break_signal = PORT_BREAK_DURATION;
-  else if (p_port->local_ctrl.modem_signal == old_modem_signal)
-    return (PORT_SUCCESS);
-
-  port_start_control(p_port);
-
-  RFCOMM_TRACE_EVENT(
-      "PORT_Control DTR_DSR : %d, RTS_CTS : %d, RI : %d, DCD : %d",
-      ((p_port->local_ctrl.modem_signal & MODEM_SIGNAL_DTRDSR) ? 1 : 0),
-      ((p_port->local_ctrl.modem_signal & MODEM_SIGNAL_RTSCTS) ? 1 : 0),
-      ((p_port->local_ctrl.modem_signal & MODEM_SIGNAL_RI) ? 1 : 0),
-      ((p_port->local_ctrl.modem_signal & MODEM_SIGNAL_DCD) ? 1 : 0));
-
-  return (PORT_SUCCESS);
-}
-
-/*******************************************************************************
- *
- * Function         PORT_FlowControl
- *
- * Description      This function directs a specified connection to pass
- *                  flow control message to the peer device.  Enable flag passed
- *                  shows if port can accept more data.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  enable     - enables data flow
- *
- ******************************************************************************/
-int PORT_FlowControl(uint16_t handle, bool enable) {
-  tPORT* p_port;
-  bool old_fc;
-  uint32_t events;
-
-  RFCOMM_TRACE_API("PORT_FlowControl() handle:%d enable: %d", handle, enable);
-
-  /* Check if handle is valid to avoid crashing */
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  if (!p_port->rfc.p_mcb) {
-    return (PORT_NOT_OPENED);
-  }
-
-  p_port->rx.user_fc = !enable;
-
-  if (p_port->rfc.p_mcb->flow == PORT_FC_CREDIT) {
-    if (!p_port->rx.user_fc) {
-      port_flow_control_peer(p_port, true, 0);
-    }
-  } else {
-    old_fc = p_port->local_ctrl.fc;
-
-    /* FC is set if user is set or peer is set */
-    p_port->local_ctrl.fc = (p_port->rx.user_fc | p_port->rx.peer_fc);
-
-    if (p_port->local_ctrl.fc != old_fc) port_start_control(p_port);
-  }
-
-  /* Need to take care of the case when we could not deliver events */
-  /* to the application because we were flow controlled */
-  if (enable && (p_port->rx.queue_size != 0)) {
-    events = PORT_EV_RXCHAR;
-    if (p_port->rx_flag_ev_pending) {
-      p_port->rx_flag_ev_pending = false;
-      events |= PORT_EV_RXFLAG;
-    }
-
-    events &= p_port->ev_mask;
-    if (p_port->p_callback && events) {
-      p_port->p_callback(events, p_port->handle);
-    }
-  }
-  return (PORT_SUCCESS);
-}
-/*******************************************************************************
- *
  * Function         PORT_FlowControl_MaxCredit
  *
  * Description      This function directs a specified connection to pass
@@ -892,230 +661,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_GetModemStatus
- *
- * Description      This function retrieves modem control signals.  Normally
- *                  application will call this function after a callback
- *                  function is called with notification that one of signals
- *                  has been changed.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  p_signal   - specify the pointer to control signals info
- *
- ******************************************************************************/
-int PORT_GetModemStatus(uint16_t handle, uint8_t* p_signal) {
-  tPORT* p_port;
-
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  *p_signal = p_port->peer_ctrl.modem_signal;
-
-  RFCOMM_TRACE_API("PORT_GetModemStatus() handle:%d signal:%x", handle,
-                   *p_signal);
-
-  return (PORT_SUCCESS);
-}
-
-/*******************************************************************************
- *
- * Function         PORT_ClearError
- *
- * Description      This function retreives information about a communications
- *                  error and reports current status of a connection.  The
- *                  function should be called when an error occures to clear
- *                  the connection error flag and to enable additional read
- *                  and write operations.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  p_errors   - pointer of the variable to receive error codes
- *                  p_status   - pointer to the tPORT_STATUS structur to receive
- *                               connection status
- *
- ******************************************************************************/
-int PORT_ClearError(uint16_t handle, uint16_t* p_errors,
-                    tPORT_STATUS* p_status) {
-  tPORT* p_port;
-
-  RFCOMM_TRACE_API("PORT_ClearError() handle:%d", handle);
-
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  *p_errors = p_port->line_status;
-
-  /* This is the only call to clear error status.  We can not clear */
-  /* connection failed status.  To clean it port should be closed and reopened
-   */
-  p_port->line_status = (p_port->line_status & LINE_STATUS_FAILED);
-
-  PORT_GetQueueStatus(handle, p_status);
-  return (PORT_SUCCESS);
-}
-
-/*******************************************************************************
- *
- * Function         PORT_SendError
- *
- * Description      This function send a communications error to the peer device
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  errors     - receive error codes
- *
- ******************************************************************************/
-int PORT_SendError(uint16_t handle, uint8_t errors) {
-  tPORT* p_port;
-
-  RFCOMM_TRACE_API("PORT_SendError() handle:%d errors:0x%x", handle, errors);
-
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  if (!p_port->rfc.p_mcb) {
-    return (PORT_NOT_OPENED);
-  }
-
-  RFCOMM_LineStatusReq(p_port->rfc.p_mcb, p_port->dlci, errors);
-  return (PORT_SUCCESS);
-}
-
-/*******************************************************************************
- *
- * Function         PORT_GetQueueStatus
- *
- * Description      This function reports current status of a connection.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  p_status   - pointer to the tPORT_STATUS structur to receive
- *                               connection status
- *
- ******************************************************************************/
-int PORT_GetQueueStatus(uint16_t handle, tPORT_STATUS* p_status) {
-  tPORT* p_port;
-
-  /* RFCOMM_TRACE_API ("PORT_GetQueueStatus() handle:%d", handle); */
-
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  p_status->in_queue_size = (uint16_t)p_port->rx.queue_size;
-  p_status->out_queue_size = (uint16_t)p_port->tx.queue_size;
-
-  p_status->mtu_size = (uint16_t)p_port->peer_mtu;
-
-  p_status->flags = 0;
-
-  if (!(p_port->peer_ctrl.modem_signal & PORT_CTSRTS_ON))
-    p_status->flags |= PORT_FLAG_CTS_HOLD;
-
-  if (!(p_port->peer_ctrl.modem_signal & PORT_DTRDSR_ON))
-    p_status->flags |= PORT_FLAG_DSR_HOLD;
-
-  if (!(p_port->peer_ctrl.modem_signal & PORT_DCD_ON))
-    p_status->flags |= PORT_FLAG_RLSD_HOLD;
-
-  return (PORT_SUCCESS);
-}
-
-/*******************************************************************************
- *
- * Function         PORT_Purge
- *
- * Description      This function discards all the data from the output or
- *                  input queues of the specified connection.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  purge_flags - specify the action to take.
- *
- ******************************************************************************/
-int PORT_Purge(uint16_t handle, uint8_t purge_flags) {
-  tPORT* p_port;
-  BT_HDR* p_buf;
-  uint16_t count;
-  uint32_t events;
-
-  RFCOMM_TRACE_API("PORT_Purge() handle:%d flags:0x%x", handle, purge_flags);
-
-  /* Check if handle is valid to avoid crashing */
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  if (purge_flags & PORT_PURGE_RXCLEAR) {
-    mutex_global_lock(); /* to prevent missing credit */
-
-    count = fixed_queue_length(p_port->rx.queue);
-
-    while ((p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_port->rx.queue)) != NULL)
-      osi_free(p_buf);
-
-    p_port->rx.queue_size = 0;
-
-    mutex_global_unlock();
-
-    /* If we flowed controlled peer based on rx_queue size enable data again */
-    if (count) port_flow_control_peer(p_port, true, count);
-  }
-
-  if (purge_flags & PORT_PURGE_TXCLEAR) {
-    mutex_global_lock(); /* to prevent tx.queue_size from being negative */
-
-    while ((p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_port->tx.queue)) != NULL)
-      osi_free(p_buf);
-
-    p_port->tx.queue_size = 0;
-
-    mutex_global_unlock();
-
-    events = PORT_EV_TXEMPTY;
-
-    events |= port_flow_control_user(p_port);
-
-    events &= p_port->ev_mask;
-
-    if ((p_port->p_callback != NULL) && events)
-      (p_port->p_callback)(events, p_port->handle);
-  }
-
-  return (PORT_SUCCESS);
-}
-
-/*******************************************************************************
- *
  * Function         PORT_ReadData
  *
  * Description      Normally not GKI aware application will call this function
@@ -1214,56 +759,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_Read
- *
- * Description      Normally application will call this function after receiving
- *                  PORT_EV_RXCHAR event.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  pp_buf      - pointer to address of buffer with data,
- *
- ******************************************************************************/
-int PORT_Read(uint16_t handle, BT_HDR** pp_buf) {
-  tPORT* p_port;
-  BT_HDR* p_buf;
-
-  RFCOMM_TRACE_API("PORT_Read() handle:%d", handle);
-
-  /* Check if handle is valid to avoid crashing */
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  if (p_port->line_status) {
-    return (PORT_LINE_ERR);
-  }
-
-  mutex_global_lock();
-
-  p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_port->rx.queue);
-  if (p_buf) {
-    p_port->rx.queue_size -= p_buf->len;
-
-    mutex_global_unlock();
-
-    /* If rfcomm suspended traffic from the peer based on the rx_queue_size */
-    /* check if it can be resumed now */
-    port_flow_control_peer(p_port, true, 1);
-  } else {
-    mutex_global_unlock();
-  }
-
-  *pp_buf = p_buf;
-  return (PORT_SUCCESS);
-}
-
-/*******************************************************************************
- *
  * Function         port_write
  *
  * Description      This function when a data packet is received from the apper
@@ -1322,64 +817,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_Write
- *
- * Description      This function when a data packet is received from the apper
- *                  layer task.
- *
- * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
- *                  pp_buf      - pointer to address of buffer with data,
- *
- ******************************************************************************/
-int PORT_Write(uint16_t handle, BT_HDR* p_buf) {
-  tPORT* p_port;
-  uint32_t event = 0;
-  int rc;
-
-  RFCOMM_TRACE_API("PORT_Write() handle:%d", handle);
-
-  /* Check if handle is valid to avoid crashing */
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    osi_free(p_buf);
-    return (PORT_BAD_HANDLE);
-  }
-
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    osi_free(p_buf);
-    return (PORT_NOT_OPENED);
-  }
-
-  if (p_port->line_status) {
-    RFCOMM_TRACE_WARNING("PORT_Write: Data dropped line_status:0x%x",
-                         p_port->line_status);
-    osi_free(p_buf);
-    return (PORT_LINE_ERR);
-  }
-
-  rc = port_write(p_port, p_buf);
-  event |= port_flow_control_user(p_port);
-
-  switch (rc) {
-    case PORT_TX_FULL:
-      event |= PORT_EV_ERR;
-      break;
-
-    case PORT_SUCCESS:
-      event |= (PORT_EV_TXCHAR | PORT_EV_TXEMPTY);
-      break;
-  }
-  /* Mask out all events that are not of interest to user */
-  event &= p_port->ev_mask;
-
-  /* Send event to the application */
-  if (p_port->p_callback && event) (p_port->p_callback)(event, p_port->handle);
-
-  return (PORT_SUCCESS);
-}
-/*******************************************************************************
- *
  * Function         PORT_WriteDataCO
  *
  * Description      Normally not GKI aware application will call this function
@@ -1647,46 +1084,6 @@
 
 /*******************************************************************************
  *
- * Function         PORT_Test
- *
- * Description      Application can call this function to send RFCOMM Test frame
- *
- * Parameters:      handle      - Handle returned in the RFCOMM_CreateConnection
- *                  p_data      - Data area
- *                  max_len     - Byte count requested
- *
- ******************************************************************************/
-int PORT_Test(uint16_t handle, uint8_t* p_data, uint16_t len) {
-  tPORT* p_port;
-
-  RFCOMM_TRACE_API("PORT_Test() len:%d", len);
-
-  if ((handle == 0) || (handle > MAX_RFC_PORTS)) {
-    return (PORT_BAD_HANDLE);
-  }
-  p_port = &rfc_cb.port.port[handle - 1];
-
-  if (!p_port->in_use || (p_port->state == PORT_STATE_CLOSED)) {
-    return (PORT_NOT_OPENED);
-  }
-
-  if (len > ((p_port->mtu == 0) ? RFCOMM_DEFAULT_MTU : p_port->mtu)) {
-    return (PORT_UNKNOWN_ERROR);
-  }
-
-  BT_HDR* p_buf = (BT_HDR*)osi_malloc(RFCOMM_CMD_BUF_SIZE);
-  p_buf->offset = L2CAP_MIN_OFFSET + RFCOMM_MIN_OFFSET + 2;
-  p_buf->len = len;
-
-  memcpy((uint8_t*)(p_buf + 1) + p_buf->offset, p_data, p_buf->len);
-
-  rfc_send_test(p_port->rfc.p_mcb, true, p_buf);
-
-  return (PORT_SUCCESS);
-}
-
-/*******************************************************************************
- *
  * Function         RFCOMM_Init
  *
  * Description      This function is called to initialize RFCOMM layer
diff --git a/system/stack/rfcomm/port_int.h b/system/stack/rfcomm/port_int.h
index ecd8fbc..01eb95f 100644
--- a/system/stack/rfcomm/port_int.h
+++ b/system/stack/rfcomm/port_int.h
@@ -32,17 +32,6 @@
 #include "port_api.h"
 #include "rfcdefs.h"
 
-/* Local events passed when application event is sent from the api to PORT */
-/* ???*/
-#define PORT_EVENT_OPEN (1 | BT_EVT_TO_BTU_SP_EVT)
-#define PORT_EVENT_CONTROL (2 | BT_EVT_TO_BTU_SP_EVT)
-#define PORT_EVENT_SET_STATE (3 | BT_EVT_TO_BTU_SP_EVT)
-#define PORT_EVENT_SET_CALLBACK (5 | BT_EVT_TO_BTU_SP_EVT)
-#define PORT_EVENT_WRITE (6 | BT_EVT_TO_BTU_SP_EVT)
-#define PORT_EVENT_PURGE (7 | BT_EVT_TO_BTU_SP_EVT)
-#define PORT_EVENT_SEND_ERROR (8 | BT_EVT_TO_BTU_SP_EVT)
-#define PORT_EVENT_FLOW_CONTROL (9 | BT_EVT_TO_BTU_SP_EVT)
-
 /*
  * Flow control configuration values for the mux
 */
@@ -114,12 +103,6 @@
  * RFCOMM Port Connection Control Block
 */
 typedef struct {
-#define RFC_PORT_STATE_IDLE 0
-#define RFC_PORT_STATE_WAIT_START 1
-#define RFC_PORT_STATE_OPENING 2
-#define RFC_PORT_STATE_OPENED 3
-#define RFC_PORT_STATE_CLOSING 4
-
   uint8_t state; /* Current state of the connection */
 
 #define RFC_RSP_PN 0x01