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

Commit 35b3ec37 authored by Chris Manton's avatar Chris Manton
Browse files

Streamline stack/l2cap/l2c_ble::l2cble_notify_le_connection

Towards readable code

Bug: 163134718
Tag: #refactor
Test: act.py -tc BleCocTest
Test: ble paired 2 phones
Test: classic paired Bose SoundLink
Change-Id: I1ffb5df7acd8f616822ec3eeacef7d88d6dbc249
parent 37f080af
Loading
Loading
Loading
Loading
+11 −9
Original line number Diff line number Diff line
@@ -239,26 +239,28 @@ uint16_t L2CA_GetDisconnectReason(const RawAddress& remote_bda,
 ******************************************************************************/
void l2cble_notify_le_connection(const RawAddress& bda) {
  tL2C_LCB* p_lcb = l2cu_find_lcb_by_bd_addr(bda, BT_TRANSPORT_LE);
  tL2C_CCB* p_ccb;
  if (p_lcb == nullptr) {
    LOG_WARN("Received notification for le connection but no lcb found");
    return;
  }

  if (p_lcb != NULL && BTM_IsAclConnectionUp(bda, BT_TRANSPORT_LE) &&
  if (BTM_IsAclConnectionUp(bda, BT_TRANSPORT_LE) &&
      p_lcb->link_state != LST_CONNECTED) {
    /* update link status */
    // TODO Move this back into acl layer
    btm_establish_continue_from_address(bda, BT_TRANSPORT_LE);
    /* update l2cap link status and send callback */
    p_lcb->link_state = LST_CONNECTED;
    l2cu_process_fixed_chnl_resp(p_lcb);
  }

  if (p_lcb != NULL) {
  /* For all channels, send the event through their FSMs */
    for (p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb;
  for (tL2C_CCB* p_ccb = p_lcb->ccb_queue.p_first_ccb; p_ccb;
       p_ccb = p_ccb->p_next_ccb) {
    if (p_ccb->chnl_state == CST_CLOSED)
      l2c_csm_execute(p_ccb, L2CEVT_LP_CONNECT_CFM, NULL);
  }
}
}

/** This function is called when an HCI Connection Complete event is received.
 */