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

Commit 5701b75f authored by Pomai Ahlo's avatar Pomai Ahlo
Browse files

Rename tPORT_STATE to PortSettings

Also rename "pars" variables to "settings" for consistency

Bug: 345006660
Test: m com.android.btservices
Flag: EXEMPT mechanical refactor
Change-Id: I52f71268dfd9fe6b90d62c58212e248954a40dec
parent cc89dd93
Loading
Loading
Loading
Loading
+12 −12
Original line number Diff line number Diff line
@@ -1442,7 +1442,7 @@ void bta_jv_rfcomm_connect(tBTA_SEC sec_mask, uint8_t remote_scn, const RawAddre
                           tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) {
  uint16_t handle = 0;
  uint32_t event_mask = BTA_JV_RFC_EV_MASK;
  tPORT_STATE port_state;
  PortSettings port_settings;

  tBTA_JV bta_jv = {
          .rfc_cl_init =
@@ -1485,13 +1485,13 @@ void bta_jv_rfcomm_connect(tBTA_SEC sec_mask, uint8_t remote_scn, const RawAddre
      if (PORT_SetDataCOCallback(handle, bta_jv_port_data_co_cback) != PORT_SUCCESS) {
        log::warn("Unable to set RFCOMM client data callback handle:{}", handle);
      }
      if (PORT_GetState(handle, &port_state) != PORT_SUCCESS) {
      if (PORT_GetSettings(handle, &port_settings) != PORT_SUCCESS) {
        log::warn("Unable to get RFCOMM client state handle:{}", handle);
      }

      port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);
      port_settings.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);

      if (PORT_SetState(handle, &port_state) != PORT_SUCCESS) {
      if (PORT_SetSettings(handle, &port_settings) != PORT_SUCCESS) {
        log::warn("Unable to set RFCOMM client state handle:{}", handle);
      }

@@ -1677,7 +1677,7 @@ static void bta_jv_port_event_sr_cback(uint32_t code, uint16_t port_handle) {
static tBTA_JV_PCB* bta_jv_add_rfc_port(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pcb_open) {
  uint8_t used = 0, i, listen = 0;
  uint32_t si = 0;
  tPORT_STATE port_state;
  PortSettings port_settings;
  uint32_t event_mask = BTA_JV_RFC_EV_MASK;
  tBTA_JV_PCB* p_pcb = NULL;
  tBTA_SEC sec_mask;
@@ -1733,13 +1733,13 @@ static tBTA_JV_PCB* bta_jv_add_rfc_port(tBTA_JV_RFC_CB* p_cb, tBTA_JV_PCB* p_pcb
        if (PORT_SetDataCOCallback(p_pcb->port_handle, bta_jv_port_data_co_cback) != PORT_SUCCESS) {
          log::warn("Unable to set RFCOMM server data callback handle:{}", p_pcb->port_handle);
        }
        if (PORT_GetState(p_pcb->port_handle, &port_state) != PORT_SUCCESS) {
        if (PORT_GetSettings(p_pcb->port_handle, &port_settings) != PORT_SUCCESS) {
          log::warn("Unable to get RFCOMM server state handle:{}", p_pcb->port_handle);
        }

        port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);
        port_settings.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);

        if (PORT_SetState(p_pcb->port_handle, &port_state) != PORT_SUCCESS) {
        if (PORT_SetSettings(p_pcb->port_handle, &port_settings) != 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);
@@ -1762,7 +1762,7 @@ void bta_jv_rfcomm_start_server(tBTA_SEC sec_mask, uint8_t local_scn, uint8_t ma
                                tBTA_JV_RFCOMM_CBACK* p_cback, uint32_t rfcomm_slot_id) {
  uint16_t handle = 0;
  uint32_t event_mask = BTA_JV_RFC_EV_MASK;
  tPORT_STATE port_state;
  PortSettings port_settings;
  tBTA_JV_RFC_CB* p_cb = NULL;
  tBTA_JV_PCB* p_pcb;
  tBTA_JV_RFCOMM_START evt_data;
@@ -1800,13 +1800,13 @@ void bta_jv_rfcomm_start_server(tBTA_SEC sec_mask, uint8_t local_scn, uint8_t ma
        PORT_SUCCESS) {
      log::warn("Unable to set RFCOMM server event mask and callback handle:{}", handle);
    }
    if (PORT_GetState(handle, &port_state) != PORT_SUCCESS) {
    if (PORT_GetSettings(handle, &port_settings) != PORT_SUCCESS) {
      log::warn("Unable to get RFCOMM server state handle:{}", handle);
    }

    port_state.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);
    port_settings.fc_type = (PORT_FC_CTS_ON_INPUT | PORT_FC_CTS_ON_OUTPUT);

    if (PORT_SetState(handle, &port_state) != PORT_SUCCESS) {
    if (PORT_SetSettings(handle, &port_settings) != PORT_SUCCESS) {
      log::warn("Unable to set RFCOMM port state handle:{}", handle);
    }
  } while (0);
+9 −10
Original line number Diff line number Diff line
@@ -38,7 +38,7 @@
 * Define port settings structure send from the application in the
 * set settings request, or to the application in the set settings indication.
 */
typedef struct {
struct PortSettings {
#define PORT_BAUD_RATE_9600 0x03

  uint8_t baud_rate;
@@ -70,8 +70,7 @@ typedef struct {

#define PORT_XOFF_DC3 0x13
  uint8_t xoff_char;

} tPORT_STATE;
};

/*
 * Define the callback function prototypes.  Parameters are specific
@@ -350,28 +349,28 @@ typedef void(tPORT_MGMT_CALLBACK)(const tPORT_RESULT code, uint16_t port_handle)
 * Function         PORT_SetState
 *
 * Description      This function configures connection according to the
 *                  specifications in the tPORT_STATE structure.
 *                  specifications in the PortSettings structure.
 *
 * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
 *                  p_settings - Pointer to a tPORT_STATE structure containing
 *                  p_settings - Pointer to a PortSettings structure containing
 *                               configuration information for the connection.
 *
 ******************************************************************************/
[[nodiscard]] int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings);
[[nodiscard]] int PORT_SetSettings(uint16_t handle, PortSettings* p_settings);

/*******************************************************************************
 *
 * Function         PORT_GetState
 * Function         PORT_GetSettings
 *
 * Description      This function is called to fill tPORT_STATE structure
 * Description      This function is called to fill PortSettings structure
 *                  with the current control settings for the port
 *
 * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
 *                  p_settings - Pointer to a tPORT_STATE structure in which
 *                  p_settings - Pointer to a PortSettings structure in which
 *                               configuration information is returned.
 *
 ******************************************************************************/
[[nodiscard]] int PORT_GetState(uint16_t handle, tPORT_STATE* p_settings);
[[nodiscard]] int PORT_GetSettings(uint16_t handle, PortSettings* p_settings);

/*******************************************************************************
 *
+14 −14
Original line number Diff line number Diff line
@@ -561,21 +561,21 @@ bool PORT_IsCollisionDetected(RawAddress bd_addr) {

/*******************************************************************************
 *
 * Function         PORT_SetState
 * Function         PORT_SetSettings
 *
 * Description      This function configures connection according to the
 *                  specifications in the tPORT_STATE structure.
 *                  specifications in the PortSettings structure.
 *
 * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
 *                  p_settings - Pointer to a tPORT_STATE structure containing
 *                  p_settings - Pointer to a PortSettings structure containing
 *                               configuration information for the connection.
 *
 *
 ******************************************************************************/
int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings) {
int PORT_SetSettings(uint16_t handle, PortSettings* p_settings) {
  uint8_t baud_rate;

  log::verbose("PORT_SetState() handle:{}", handle);
  log::verbose("PORT_SetSettings() handle:{}", handle);
  tPORT* p_port = get_port_from_handle(handle);
  if (p_port == nullptr) {
    log::error("Unable to get RFCOMM port control block bad handle:{}", handle);
@@ -590,10 +590,10 @@ int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings) {
    return PORT_LINE_ERR;
  }

  log::verbose("PORT_SetState() handle:{} FC_TYPE:0x{:x}", handle, p_settings->fc_type);
  log::verbose("PORT_SetSettings() handle:{} FC_TYPE:0x{:x}", handle, p_settings->fc_type);

  baud_rate = p_port->user_port_pars.baud_rate;
  p_port->user_port_pars = *p_settings;
  baud_rate = p_port->user_port_settings.baud_rate;
  p_port->user_port_settings = *p_settings;

  /* for now we've been asked to pass only baud rate */
  if (baud_rate != p_settings->baud_rate) {
@@ -604,18 +604,18 @@ int PORT_SetState(uint16_t handle, tPORT_STATE* p_settings) {

/*******************************************************************************
 *
 * Function         PORT_GetState
 * Function         PORT_GetSettings
 *
 * Description      This function is called to fill tPORT_STATE structure
 * Description      This function is called to fill PortSettings structure
 *                  with the curremt control settings for the port
 *
 * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
 *                  p_settings - Pointer to a tPORT_STATE structure in which
 *                  p_settings - Pointer to a PortSettings structure in which
 *                               configuration information is returned.
 *
 ******************************************************************************/
int PORT_GetState(uint16_t handle, tPORT_STATE* p_settings) {
  log::verbose("PORT_GetState() handle:{}", handle);
int PORT_GetSettings(uint16_t handle, PortSettings* p_settings) {
  log::verbose("PORT_GetSettings() handle:{}", handle);

  tPORT* p_port = get_port_from_handle(handle);
  if (p_port == nullptr) {
@@ -631,7 +631,7 @@ int PORT_GetState(uint16_t handle, tPORT_STATE* p_settings) {
    return PORT_LINE_ERR;
  }

  *p_settings = p_port->user_port_pars;
  *p_settings = p_port->user_port_settings;
  return PORT_SUCCESS;
}

+2 −2
Original line number Diff line number Diff line
@@ -172,8 +172,8 @@ typedef struct {
  tPORT_DATA tx; /* Control block for data from app to peer */
  tPORT_DATA rx; /* Control block for data from peer to app */

  tPORT_STATE user_port_pars; /* Port parameters for user connection */
  tPORT_STATE peer_port_pars; /* Port parameters for user connection */
  PortSettings user_port_settings; /* Port parameters for user connection */
  PortSettings peer_port_settings; /* Port parameters for peer connection */

  tPORT_CTRL local_ctrl;
  tPORT_CTRL peer_ctrl;
+9 −7
Original line number Diff line number Diff line
@@ -142,7 +142,7 @@ void port_start_par_neg(tPORT* p_port) {
    return;
  }

  RFCOMM_PortParameterNegotiationRequest(p_mcb, p_port->dlci, &p_port->user_port_pars);
  RFCOMM_PortParameterNegotiationRequest(p_mcb, p_port->dlci, &p_port->user_port_settings);
}

/*******************************************************************************
@@ -519,7 +519,7 @@ void PORT_DlcEstablishCnf(tRFC_MCB* p_mcb, uint8_t dlci, uint16_t mtu, uint16_t
 *                  allocated before meaning that application already made open.
 *
 ******************************************************************************/
void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, uint16_t param_mask) {
void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, PortSettings* p_settings, uint16_t param_mask) {
  tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci);

  log::verbose("PORT_PortNegInd");
@@ -528,15 +528,15 @@ void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, uint16_
    /* This can be a first request for this port */
    p_port = port_find_dlci_port(dlci);
    if (!p_port) {
      RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_pars, 0);
      RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_settings, 0);
      return;
    }
    p_mcb->port_handles[dlci] = p_port->handle;
  }

  /* Check if the flow control is acceptable on local side */
  p_port->peer_port_pars = *p_pars;
  RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_pars, param_mask);
  p_port->peer_port_settings = *p_settings;
  RFCOMM_PortParameterNegotiationResponse(p_mcb, dlci, p_settings, param_mask);
}

/*******************************************************************************
@@ -547,7 +547,8 @@ void PORT_PortNegInd(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* p_pars, uint16_
 *                  state for the port.  Propagate change to the user.
 *
 ******************************************************************************/
void PORT_PortNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, tPORT_STATE* /* p_pars */, uint16_t result) {
void PORT_PortNegCnf(tRFC_MCB* p_mcb, uint8_t dlci, PortSettings* /* p_settings */,
                     uint16_t result) {
  tPORT* p_port = port_find_mcb_dlci_port(p_mcb, dlci);

  log::verbose("PORT_PortNegCnf");
@@ -822,7 +823,8 @@ void PORT_DataInd(tRFC_MCB* p_mcb, uint8_t dlci, BT_HDR* p_buf) {
  }
  /* If user registered to receive notification when a particular byte is */
  /* received we mast check all received bytes */
  if (((rx_char1 = p_port->user_port_pars.rx_char1) != 0) && (p_port->ev_mask & PORT_EV_RXFLAG)) {
  if (((rx_char1 = p_port->user_port_settings.rx_char1) != 0) &&
      (p_port->ev_mask & PORT_EV_RXFLAG)) {
    for (i = 0, p = (uint8_t*)(p_buf + 1) + p_buf->offset; i < p_buf->len; i++) {
      if (*p++ == rx_char1) {
        events |= PORT_EV_RXFLAG;
Loading