Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit e30b2fbe authored by Pomai Ahlo's avatar Pomai Ahlo Committed by Gerrit Code Review
Browse files

Merge changes I4d7d68ec,Ie9031b49 into main

* changes:
  RFCOMM cpplint: logging, comment, and syntax
  RFCOMM: move from bt_target to rfcdefs.h
parents b937bca4 f55e2de7
Loading
Loading
Loading
Loading
+7 −13
Original line number Diff line number Diff line
@@ -21,19 +21,19 @@
 *  This is the public interface file the BTA Java I/F
 *
 ******************************************************************************/
#ifndef BTA_JV_API_H
#define BTA_JV_API_H
#pragma once

#include <cstdint>
#include <memory>
#include <string>

#include "bta/include/bta_api.h"
#include "bta_sec_api.h"
#include "bta/include/bta_sec_api.h"
#include "include/macros.h"
#include "internal_include/bt_target.h"
#include "stack/include/bt_hdr.h"
#include "stack/include/l2c_api.h"
#include "stack/include/rfcdefs.h"
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"

@@ -78,9 +78,8 @@ typedef uint8_t tBTA_JV_L2CAP_REASON;
#define BTA_JV_MAX_UUIDS SDP_MAX_UUID_FILTERS
#define BTA_JV_MAX_ATTRS SDP_MAX_ATTR_FILTERS
#define BTA_JV_MAX_SDP_REC SDP_MAX_RECORDS
#define BTA_JV_MAX_L2C_CONN                                                    \
  GAP_MAX_CONNECTIONS /* GAP handle is used as index, hence do not change this \
                         value */
/* GAP handle is used as index, hence do not change this value */
#define BTA_JV_MAX_L2C_CONN GAP_MAX_CONNECTIONS
#define BTA_JV_MAX_RFC_CONN MAX_RFC_PORTS

#ifndef BTA_JV_DEF_RFC_MTU
@@ -271,7 +270,6 @@ typedef struct {
  int32_t tx_mtu;        /* The transmit MTU */
  void** p_p_cback;      /* set them for new socket */
  void** p_user_data;    /* set them for new socket */

} tBTA_JV_L2CAP_LE_OPEN;

/* data associated with BTA_JV_L2CAP_CLOSE_EVT */
@@ -310,8 +308,7 @@ typedef struct {
  tBTA_JV_STATUS status; /* Whether the operation succeeded or failed. */
  uint32_t handle;       /* The connection handle */
  uint32_t req_id;       /* The req_id in the associated BTA_JvL2capRead() */
  uint8_t* p_data;       /* This points the same location as the p_data
                          * parameter in BTA_JvL2capRead () */
  uint8_t* p_data;       /* Points to the same location as p_data parameter in BTA_JvL2capRead() */
  uint16_t len;          /* The length of the data read. */
} tBTA_JV_L2CAP_READ;

@@ -423,8 +420,7 @@ typedef union {
  tBTA_JV_RFCOMM_CL_INIT rfc_cl_init;   /* BTA_JV_RFCOMM_CL_INIT_EVT */
  tBTA_JV_RFCOMM_CONG rfc_cong;         /* BTA_JV_RFCOMM_CONG_EVT */
  tBTA_JV_RFCOMM_WRITE rfc_write;       /* BTA_JV_RFCOMM_WRITE_EVT */
  tBTA_JV_DATA_IND data_ind;            /* BTA_JV_L2CAP_DATA_IND_EVT
                                           BTA_JV_RFCOMM_DATA_IND_EVT */
  tBTA_JV_DATA_IND data_ind;            /* BTA_JV_L2CAP_DATA_IND_EVT, BTA_JV_RFCOMM_DATA_IND_EVT */
  tBTA_JV_LE_DATA_IND le_data_ind;      /* BTA_JV_L2CAP_LE_DATA_IND_EVT */
  tBTA_JV_L2CAP_LE_OPEN l2c_le_open;    /* BTA_JV_L2CAP_OPEN_EVT */
} tBTA_JV;
@@ -760,5 +756,3 @@ tBTA_JV_STATUS BTA_JvSetPmProfile(uint32_t handle, tBTA_JV_PM_ID app_id,
 *
 ******************************************************************************/
uint16_t BTA_JvRfcommGetPortHdl(uint32_t handle);

#endif /* BTA_JV_API_H */
+4 −3
Original line number Diff line number Diff line
@@ -50,6 +50,7 @@
#include "stack/include/gap_api.h"
#include "stack/include/l2cdefs.h"
#include "stack/include/port_api.h"
#include "stack/include/rfcdefs.h"
#include "stack/include/sdp_api.h"
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"
@@ -1737,6 +1738,7 @@ static tBTA_JV_PCB* bta_jv_add_rfc_port(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pcb
        port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);

        if (PORT_SetState(p_pcb->port_handle, &port_state) != PORT_SUCCESS) {
          log::warn("Unable to set RFCOMM server state handle:{}", p_pcb->port_handle);
        }
        p_pcb->handle = BTA_JV_RFC_H_S_TO_HDL(p_cb->handle, si);
        log::verbose("p_pcb->handle=0x{:x}, curr_sess={}", p_pcb->handle, p_cb->curr_sess);
@@ -1804,7 +1806,7 @@ void bta_jv_rfcomm_start_server(tBTA_SEC sec_mask, uint8_t local_scn, uint8_t ma

    if (PORT_SetState(handle, &port_state) != PORT_SUCCESS) {
      log::warn("Unable to set RFCOMM port state handle:{}", handle);
    };
    }
  } while (0);

  tBTA_JV bta_jv;
@@ -1890,8 +1892,7 @@ void bta_jv_set_pm_profile(uint32_t handle, tBTA_JV_PM_ID app_id, tBTA_JV_CONN_S
    if (status != tBTA_JV_STATUS::SUCCESS) {
      log::warn("free pm cb failed: reason={}", bta_jv_status_text(status));
    }
  } else /* set PM control block */
  {
  } else { /* set PM control block */
    p_cb = bta_jv_alloc_set_pm_profile_cb(handle, app_id);

    if (NULL != p_cb) {
+1 −90
Original line number Diff line number Diff line
@@ -17,8 +17,7 @@
 *
 ******************************************************************************/

#ifndef BT_TARGET_H
#define BT_TARGET_H
#pragma once

#ifndef FALSE
#define FALSE false
@@ -39,10 +38,6 @@
#define BTUI_OPS_FORMATS (BTA_OP_VCARD21_MASK | BTA_OP_ANY_MASK)
#endif

#ifndef BTA_RFC_MTU_SIZE
#define BTA_RFC_MTU_SIZE (L2CAP_MTU_SIZE - L2CAP_MIN_OFFSET - RFCOMM_DATA_OVERHEAD)
#endif

#ifndef BTA_PAN_INCLUDED
#define BTA_PAN_INCLUDED TRUE
#endif
@@ -117,16 +112,6 @@
#define SDP_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif

/* Sends RFCOMM command packets. */
#ifndef RFCOMM_CMD_BUF_SIZE
#define RFCOMM_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE
#endif

/* Sends RFCOMM data packets. */
#ifndef RFCOMM_DATA_BUF_SIZE
#define RFCOMM_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE
#endif

/* Sends L2CAP packets to the peer and HCI messages to the controller. */
#ifndef L2CAP_CMD_BUF_SIZE
#define L2CAP_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE
@@ -487,72 +472,6 @@
#define SDP_MTU_SIZE 1024
#endif

/******************************************************************************
 *
 * RFCOMM
 *
 *****************************************************************************/

/* The maximum number of ports supported. */
#ifndef MAX_RFC_PORTS
#define MAX_RFC_PORTS 30
#endif

/* The maximum simultaneous links to different devices. */
#ifndef MAX_BD_CONNECTIONS
#define MAX_BD_CONNECTIONS 16
#endif

/* The port receive queue low watermark level, in bytes. */
#ifndef PORT_RX_LOW_WM
#define PORT_RX_LOW_WM (BTA_RFC_MTU_SIZE * PORT_RX_BUF_LOW_WM)
#endif

/* The port receive queue high watermark level, in bytes. */
#ifndef PORT_RX_HIGH_WM
#define PORT_RX_HIGH_WM (BTA_RFC_MTU_SIZE * PORT_RX_BUF_HIGH_WM)
#endif

/* The port receive queue critical watermark level, in bytes. */
#ifndef PORT_RX_CRITICAL_WM
#define PORT_RX_CRITICAL_WM (BTA_RFC_MTU_SIZE * PORT_RX_BUF_CRITICAL_WM)
#endif

/* The port receive queue low watermark level, in number of buffers. */
#ifndef PORT_RX_BUF_LOW_WM
#define PORT_RX_BUF_LOW_WM 4
#endif

/* The port receive queue high watermark level, in number of buffers. */
#ifndef PORT_RX_BUF_HIGH_WM
#define PORT_RX_BUF_HIGH_WM 10
#endif

/* The port receive queue critical watermark level, in number of buffers. */
#ifndef PORT_RX_BUF_CRITICAL_WM
#define PORT_RX_BUF_CRITICAL_WM 15
#endif

/* The port transmit queue high watermark level, in bytes. */
#ifndef PORT_TX_HIGH_WM
#define PORT_TX_HIGH_WM (BTA_RFC_MTU_SIZE * PORT_TX_BUF_HIGH_WM)
#endif

/* The port transmit queue critical watermark level, in bytes. */
#ifndef PORT_TX_CRITICAL_WM
#define PORT_TX_CRITICAL_WM (BTA_RFC_MTU_SIZE * PORT_TX_BUF_CRITICAL_WM)
#endif

/* The port transmit queue high watermark level, in number of buffers. */
#ifndef PORT_TX_BUF_HIGH_WM
#define PORT_TX_BUF_HIGH_WM 10
#endif

/* The port transmit queue high watermark level, in number of buffers. */
#ifndef PORT_TX_BUF_CRITICAL_WM
#define PORT_TX_BUF_CRITICAL_WM 15
#endif

/******************************************************************************
 *
 * BNEP
@@ -766,11 +685,3 @@
#ifndef BTA_EIR_SERVER_NUM_CUSTOM_UUID
#define BTA_EIR_SERVER_NUM_CUSTOM_UUID 8
#endif

/******************************************************************************
 *
 * Tracing:  Include trace header file here.
 *
 *****************************************************************************/

#endif /* BT_TARGET_H */
+54 −3
Original line number Diff line number Diff line
@@ -22,18 +22,34 @@
 *
 ****************************************************************************/

#ifndef RFCDEFS_H
#define RFCDEFS_H
#pragma once

/*
 *  Server Channel Numbers (SCN) range between 1 and 30, inclusive
 */
#define RFCOMM_MAX_SCN 30

/*
 * The maximum number of ports supported.
 */
#define MAX_RFC_PORTS 30

/*
 * The maximum simultaneous links to different devices.
 */
#define MAX_BD_CONNECTIONS 16

/*
 *  If nothing is negotiated MTU should be 127
 */
#define RFCOMM_DEFAULT_MTU 127

/*
 * RFCOMM buffer sizes
 */
#define RFCOMM_CMD_BUF_SIZE BT_SMALL_BUFFER_SIZE     // command packet buffer size
#define RFCOMM_DATA_BUF_SIZE BT_DEFAULT_BUFFER_SIZE  // data packet buffer size

/*
 * Define used by RFCOMM TS frame types
 */
@@ -235,4 +251,39 @@

#define RFCOMM_MX_RLS 0x50
#define RFCOMM_MX_RLS_LEN 2
#endif

/*
 * Define RFCOMM port rx and tx queue watermarks
 */
// MTU size used to calculate watermark levels
#define BTA_RFC_MTU_SIZE (L2CAP_MTU_SIZE - L2CAP_MIN_OFFSET - RFCOMM_DATA_OVERHEAD)

// The port receive queue low watermark level, in number of buffers.
#define PORT_RX_BUF_LOW_WM 4

// The port receive queue high watermark level, in number of buffers.
#define PORT_RX_BUF_HIGH_WM 10

// The port receive queue critical watermark level, in number of buffers.
#define PORT_RX_BUF_CRITICAL_WM 15

// The port receive queue low watermark level, in bytes.
#define PORT_RX_LOW_WM (BTA_RFC_MTU_SIZE * PORT_RX_BUF_LOW_WM)

// The port receive queue high watermark level, in bytes.
#define PORT_RX_HIGH_WM (BTA_RFC_MTU_SIZE * PORT_RX_BUF_HIGH_WM)

// The port receive queue critical watermark level, in bytes.
#define PORT_RX_CRITICAL_WM (BTA_RFC_MTU_SIZE * PORT_RX_BUF_CRITICAL_WM)

// The port transmit queue high watermark level, in number of buffers.
#define PORT_TX_BUF_HIGH_WM 10

// The port transmit queue high watermark level, in number of buffers.
#define PORT_TX_BUF_CRITICAL_WM 15

// The port transmit queue high watermark level, in bytes.
#define PORT_TX_HIGH_WM (BTA_RFC_MTU_SIZE * PORT_TX_BUF_HIGH_WM)

// The port transmit queue critical watermark level, in bytes.
#define PORT_TX_CRITICAL_WM (BTA_RFC_MTU_SIZE * PORT_TX_BUF_CRITICAL_WM)
+2 −4
Original line number Diff line number Diff line
@@ -31,7 +31,6 @@

#include <cstdint>

#include "internal_include/bt_target.h"
#include "internal_include/bt_trace.h"
#include "os/logging/log_adapter.h"
#include "osi/include/allocator.h"
@@ -40,6 +39,7 @@
#include "stack/include/bt_types.h"
#include "stack/include/bt_uuid16.h"
#include "stack/include/btm_log_history.h"
#include "stack/include/rfcdefs.h"
#include "stack/rfcomm/rfc_int.h"
#include "types/raw_address.h"

@@ -925,9 +925,7 @@ int PORT_WriteDataCO(uint16_t handle, int* p_len) {
    // if(recv(fd, (uint8_t *)(p_buf + 1) + p_buf->offset + p_buf->len,
    // available, 0) != available)
    if (!p_port->p_data_co_callback(handle, (uint8_t*)(p_buf + 1) + p_buf->offset + p_buf->len,
                                    available, DATA_CO_CALLBACK_TYPE_OUTGOING))

    {
                                    available, DATA_CO_CALLBACK_TYPE_OUTGOING)) {
      log::error("p_data_co_callback DATA_CO_CALLBACK_TYPE_OUTGOING failed, available:{}",
                 available);
      mutex_global_unlock();
Loading