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

Commit af302719 authored by Chris Manton's avatar Chris Manton
Browse files

stack::rfcomm: Re-order Event and Callback functions

Bug: 343302787
Test: m .
Flag: EXEMPT, Mechanical Refactor
Change-Id: I946812d0f4a1a9409f938a3e64f7fa8f4d95d5c8
parent 1016644b
Loading
Loading
Loading
Loading
+10 −10
Original line number Diff line number Diff line
@@ -1507,14 +1507,14 @@ void bta_jv_rfcomm_connect(tBTA_SEC sec_mask, uint8_t remote_scn,
      p_pcb->rfcomm_slot_id = rfcomm_slot_id;
      bta_jv.rfc_cl_init.use_co = true;

      if (PORT_SetEventMask(handle, event_mask) != PORT_SUCCESS) {
        log::warn("Unable to set RFCOMM client event mask handle:{}", handle);
      }
      if (PORT_SetEventCallback(handle, bta_jv_port_event_cl_cback) !=
          PORT_SUCCESS) {
        log::warn("Unable to set RFCOMM client event callback handle:{}",
                  handle);
      }
      if (PORT_SetEventMask(handle, event_mask) != PORT_SUCCESS) {
        log::warn("Unable to set RFCOMM client event mask handle:{}", handle);
      }
      if (PORT_SetDataCOCallback(handle, bta_jv_port_data_co_cback) !=
          PORT_SUCCESS) {
        log::warn("Unable to set RFCOMM client data callback handle:{}",
@@ -1772,6 +1772,10 @@ static tBTA_JV_PCB* bta_jv_add_rfc_port(tBTA_JV_RFC_CB* p_cb,
          log::warn("Unable to clear RFCOMM server keep handle flag handle:{}",
                    p_pcb->port_handle);
        }
        if (PORT_SetEventMask(p_pcb->port_handle, event_mask) != PORT_SUCCESS) {
          log::warn("Unable to set RFCOMM server event mask handle:{}",
                    p_pcb->port_handle);
        }
        if (PORT_SetEventCallback(p_pcb->port_handle,
                                  bta_jv_port_event_sr_cback) != PORT_SUCCESS) {
          log::warn("Unable to set RFCOMM server event callback handle:{}",
@@ -1782,10 +1786,6 @@ static tBTA_JV_PCB* bta_jv_add_rfc_port(tBTA_JV_RFC_CB* p_cb,
          log::warn("Unable to set RFCOMM server data callback handle:{}",
                    p_pcb->port_handle);
        }
        if (PORT_SetEventMask(p_pcb->port_handle, event_mask) != PORT_SUCCESS) {
          log::warn("Unable to set RFCOMM server event mask handle:{}",
                    p_pcb->port_handle);
        }
        if (PORT_GetState(p_pcb->port_handle, &port_state) != PORT_SUCCESS) {
          log::warn("Unable to get RFCOMM server state handle:{}",
                    p_pcb->port_handle);
@@ -1854,14 +1854,14 @@ void bta_jv_rfcomm_start_server(tBTA_SEC sec_mask, uint8_t local_scn,
      log::warn("Unable to clear RFCOMM server keep handle flag handle:{}",
                handle);
    }
    if (PORT_SetEventMask(handle, event_mask) != PORT_SUCCESS) {
      log::warn("Unable to set RFCOMM server event mask handle:{}", handle);
    }
    if (PORT_SetEventCallback(handle, bta_jv_port_event_sr_cback) !=
        PORT_SUCCESS) {
      log::warn("Unable to clear RFCOMM server event callback handle:{}",
                handle);
    }
    if (PORT_SetEventMask(handle, event_mask) != PORT_SUCCESS) {
      log::warn("Unable to set RFCOMM server event mask handle:{}", handle);
    }
    if (PORT_GetState(handle, &port_state) != PORT_SUCCESS) {
      log::warn("Unable to get RFCOMM server state handle:{}", handle);
    }
+13 −13
Original line number Diff line number Diff line
@@ -277,6 +277,19 @@ typedef void(tPORT_MGMT_CALLBACK)(const tPORT_RESULT code,
 ******************************************************************************/
[[nodiscard]] int RFCOMM_RemoveServer(uint16_t handle);

/*******************************************************************************
 *
 * Function         PORT_SetEventMask
 *
 * Description      This function is called to close the specified connection.
 *
 * Parameters:      handle - Handle of the port returned in the Open
 *                  mask   - specifies events to be enabled.  A value
 *                           of zero disables all events.
 *
 ******************************************************************************/
[[nodiscard]] int PORT_SetEventMask(uint16_t port_handle, uint32_t mask);

/*******************************************************************************
 *
 * Function         PORT_SetEventCallback
@@ -306,19 +319,6 @@ typedef void(tPORT_MGMT_CALLBACK)(const tPORT_RESULT code,

[[nodiscard]] int PORT_SetDataCOCallback(uint16_t port_handle,
                                         tPORT_DATA_CO_CALLBACK* p_port_cb);
/*******************************************************************************
 *
 * Function         PORT_SetEventMask
 *
 * Description      This function is called to close the specified connection.
 *
 * Parameters:      handle - Handle of the port returned in the Open
 *                  mask   - specifies events to be enabled.  A value
 *                           of zero disables all events.
 *
 ******************************************************************************/
[[nodiscard]] int PORT_SetEventMask(uint16_t port_handle, uint32_t mask);

/*******************************************************************************
 *
 * Function         PORT_CheckConnection
+27 −27
Original line number Diff line number Diff line
@@ -371,6 +371,33 @@ int RFCOMM_RemoveServer(uint16_t handle) {
  return (PORT_SUCCESS);
}

/*******************************************************************************
 *
 * Function         PORT_SetEventMask
 *
 * Description      This function is called to close the specified connection.
 *
 * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
 *                  mask   - Bitmask of the events the host is interested in
 *
 ******************************************************************************/
int PORT_SetEventMask(uint16_t handle, uint32_t mask) {
  log::verbose("PORT_SetEventMask() handle:{} mask:0x{:x}", handle, mask);
  tPORT* p_port = get_port_from_handle(handle);
  if (p_port == nullptr) {
    log::error("Unable to get RFCOMM port control block bad handle:{}", handle);
    return (PORT_BAD_HANDLE);
  }

  if (!p_port->in_use || (p_port->state == PORT_CONNECTION_STATE_CLOSED)) {
    return (PORT_NOT_OPENED);
  }

  p_port->ev_mask = mask;

  return (PORT_SUCCESS);
}

/*******************************************************************************
 *
 * Function         PORT_SetEventCallback
@@ -454,33 +481,6 @@ int PORT_SetDataCOCallback(uint16_t handle, tPORT_DATA_CO_CALLBACK* p_port_cb) {
  return (PORT_SUCCESS);
}

/*******************************************************************************
 *
 * Function         PORT_SetEventMask
 *
 * Description      This function is called to close the specified connection.
 *
 * Parameters:      handle     - Handle returned in the RFCOMM_CreateConnection
 *                  mask   - Bitmask of the events the host is interested in
 *
 ******************************************************************************/
int PORT_SetEventMask(uint16_t handle, uint32_t mask) {
  log::verbose("PORT_SetEventMask() handle:{} mask:0x{:x}", handle, mask);
  tPORT* p_port = get_port_from_handle(handle);
  if (p_port == nullptr) {
    log::error("Unable to get RFCOMM port control block bad handle:{}", handle);
    return (PORT_BAD_HANDLE);
  }

  if (!p_port->in_use || (p_port->state == PORT_CONNECTION_STATE_CLOSED)) {
    return (PORT_NOT_OPENED);
  }

  p_port->ev_mask = mask;

  return (PORT_SUCCESS);
}

/*******************************************************************************
 *
 * Function         PORT_CheckConnection