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

Commit 7f0f9b47 authored by Jack He's avatar Jack He Committed by Gerrit Code Review
Browse files

Merge "RFCOMM: Handle configuration for pending connection"

parents 77a14deb 99bb374e
Loading
Loading
Loading
Loading
+9 −3
Original line number Diff line number Diff line
@@ -27,6 +27,7 @@

#include "bt_common.h"
#include "bt_target.h"
#include "l2c_api.h"
#include "osi/include/alarm.h"
#include "osi/include/fixed_queue.h"
#include "port_api.h"
@@ -77,11 +78,12 @@ typedef struct {
 * RFCOMM multiplexer Control Block
*/
typedef struct {
  alarm_t* mcb_timer;   /* MCB timer */
  fixed_queue_t* cmd_q; /* Queue for command messages on this mux */
  alarm_t* mcb_timer = nullptr;   /* MCB timer */
  fixed_queue_t* cmd_q = nullptr; /* Queue for command messages on this mux */
  uint8_t port_handles[RFCOMM_MAX_DLCI + 1]; /* Array for quick access to  */
  /* port handles based on dlci        */
  RawAddress bd_addr;                    /* BD ADDR of the peer if initiator */
  RawAddress bd_addr =
      RawAddress::kEmpty;                /* BD ADDR of the peer if initiator */
  uint16_t lcid;                         /* Local cid used for this channel */
  uint16_t peer_l2cap_mtu; /* Max frame that can be sent to peer L2CAP */
  uint8_t state;           /* Current multiplexer channel state */
@@ -93,6 +95,10 @@ typedef struct {
  bool is_disc_initiator; /* true if initiated disc of port */
  uint16_t
      pending_lcid; /* store LCID for incoming connection while connecting */
  bool pending_configure_complete;       /* true if confiquration of the pending
                                            connection was completed*/
  tL2CAP_CFG_INFO pending_cfg_info = {}; /* store configure info for incoming
                                       connection while connecting */
} tRFC_MCB;

/*
+8 −0
Original line number Diff line number Diff line
@@ -181,6 +181,14 @@ void RFCOMM_ConfigInd(uint16_t lcid, tL2CAP_CFG_INFO* p_cfg) {

  if (!p_mcb) {
    RFCOMM_TRACE_ERROR("RFCOMM_ConfigInd LCID:0x%x", lcid);
    for (auto& [cid, mcb] : rfc_lcid_mcb) {
      if (mcb != nullptr && mcb->pending_lcid == lcid) {
        tL2CAP_CFG_INFO l2cap_cfg_info(*p_cfg);
        mcb->pending_configure_complete = true;
        mcb->pending_cfg_info = l2cap_cfg_info;
        return;
      }
    }
    return;
  }

+8 −0
Original line number Diff line number Diff line
@@ -592,6 +592,14 @@ void rfc_on_l2cap_error(uint16_t lcid, uint16_t result) {
        }
      }
      rfc_mx_sm_execute(p_mcb, RFC_MX_EVENT_CONN_IND, nullptr);
      if (p_mcb->pending_configure_complete) {
        LOG_INFO("Configuration of the pending connection was completed");
        p_mcb->pending_configure_complete = false;
        uintptr_t result_as_ptr = L2CAP_CFG_OK;
        rfc_mx_sm_execute(p_mcb, RFC_MX_EVENT_CONF_IND,
                          &p_mcb->pending_cfg_info);
        rfc_mx_sm_execute(p_mcb, RFC_MX_EVENT_CONF_CNF, (void*)result_as_ptr);
      }
      return;
    }