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

Commit 8247e188 authored by Archie Pusaka's avatar Archie Pusaka
Browse files

Revert "SMP: Assume L2cap tx completes immediately"

This reverts commit 13b310b3.

The assumption in the original CL "L2cap tx completes immediately"
seems to be incorrect.

Bug: 314819704
Bug: 301168932
Test: m -j
Test: Verify successful pairing with Keyboard Craft repeatedly

Change-Id: I8c13902f5d8c99001fbe1bea417eccf664904f1a
parent 6ef82796
Loading
Loading
Loading
Loading
+19 −1
Original line number Diff line number Diff line
@@ -218,7 +218,25 @@ static void smp_data_received(uint16_t channel, const RawAddress& bd_addr,
 * Description      SMP channel tx complete callback
 *
 ******************************************************************************/
static void smp_tx_complete_callback(uint16_t cid, uint16_t num_pkt) {}
static void smp_tx_complete_callback(uint16_t cid, uint16_t num_pkt) {
  tSMP_CB* p_cb = &smp_cb;

  if (p_cb->total_tx_unacked >= num_pkt) {
    p_cb->total_tx_unacked -= num_pkt;
  } else {
    LOG_ERROR("Unexpected %s: num_pkt = %d", __func__, num_pkt);
  }

  if (p_cb->total_tx_unacked == 0 && p_cb->wait_for_authorization_complete) {
    tSMP_INT_DATA smp_int_data;
    smp_int_data.status = SMP_SUCCESS;
    if (cid == L2CAP_SMP_CID) {
      smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
    } else {
      smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &smp_int_data);
    }
  }
}

/*******************************************************************************
 *
+2 −11
Original line number Diff line number Diff line
@@ -364,6 +364,7 @@ bool smp_send_msg_to_L2CAP(const RawAddress& rem_bda, BT_HDR* p_toL2CAP) {

  LOG_VERBOSE("rem_bda:%s, over_bredr:%d", ADDRESS_TO_LOGGABLE_CSTR(rem_bda),
              smp_cb.smp_over_br);
  smp_cb.total_tx_unacked += 1;

  smp_log_metrics(rem_bda, true /* outgoing */,
                  p_toL2CAP->data + p_toL2CAP->offset, p_toL2CAP->len,
@@ -372,19 +373,9 @@ bool smp_send_msg_to_L2CAP(const RawAddress& rem_bda, BT_HDR* p_toL2CAP) {
  l2cap_ret = L2CA_SendFixedChnlData(fixed_cid, rem_bda, p_toL2CAP);
  if (l2cap_ret == L2CAP_DW_FAILED) {
    LOG_ERROR("SMP failed to pass msg to L2CAP");
    smp_cb.total_tx_unacked -= 1;
    return false;
  } else {
    tSMP_CB* p_cb = &smp_cb;

    if (p_cb->wait_for_authorization_complete) {
      tSMP_INT_DATA smp_int_data;
      smp_int_data.status = SMP_SUCCESS;
      if (fixed_cid == L2CAP_SMP_CID) {
        smp_sm_event(p_cb, SMP_AUTH_CMPL_EVT, &smp_int_data);
      } else {
        smp_br_state_machine_event(p_cb, SMP_BR_AUTH_CMPL_EVT, &smp_int_data);
      }
    }
    return true;
  }
}