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

Commit 2b2c8f58 authored by Hansong Zhang's avatar Hansong Zhang
Browse files

L2cap: LE specific disconnect and write API

In shim layer we handle classic and LE separately.

For now, LE API redirects to classic.

Bug: 159815595
Tag: #refactor
Test: compile & verify basic functions working
Change-Id: I2ba1dba32f1102631671770ee603881c4b47efeb
parent 89e87d64
Loading
Loading
Loading
Loading
+18 −4
Original line number Original line Diff line number Diff line
@@ -317,8 +317,13 @@ uint16_t GAP_ConnClose(uint16_t gap_handle) {


  if (p_ccb) {
  if (p_ccb) {
    /* Check if we have a connection ID */
    /* Check if we have a connection ID */
    if (p_ccb->con_state != GAP_CCB_STATE_LISTENING)
    if (p_ccb->con_state != GAP_CCB_STATE_LISTENING) {
      if (p_ccb->transport == BT_TRANSPORT_LE) {
        L2CA_DisconnectLECocReq(p_ccb->connection_id);
      } else {
        L2CA_DisconnectReq(p_ccb->connection_id);
        L2CA_DisconnectReq(p_ccb->connection_id);
      }
    }


    gap_release_ccb(p_ccb);
    gap_release_ccb(p_ccb);


@@ -430,7 +435,12 @@ static bool gap_try_write_queued_data(tGAP_CCB* p_ccb) {
  /* Send the buffer through L2CAP */
  /* Send the buffer through L2CAP */
  BT_HDR* p_buf;
  BT_HDR* p_buf;
  while ((p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->tx_queue)) != NULL) {
  while ((p_buf = (BT_HDR*)fixed_queue_try_dequeue(p_ccb->tx_queue)) != NULL) {
    uint8_t status = L2CA_DataWrite(p_ccb->connection_id, p_buf);
    uint8_t status;
    if (p_ccb->transport == BT_TRANSPORT_LE) {
      status = L2CA_LECocDataWrite(p_ccb->connection_id, p_buf);
    } else {
      status = L2CA_DataWrite(p_ccb->connection_id, p_buf);
    }


    if (status == L2CAP_DW_CONGESTED) {
    if (status == L2CAP_DW_CONGESTED) {
      p_ccb->is_congested = true;
      p_ccb->is_congested = true;
@@ -604,7 +614,11 @@ static void gap_connect_ind(const RawAddress& bd_addr, uint16_t l2cap_cid,
    LOG(WARNING) << "*******";
    LOG(WARNING) << "*******";


    /* Disconnect because it is an unexpected connection */
    /* Disconnect because it is an unexpected connection */
    if (p_ccb->transport == BT_TRANSPORT_LE) {
      L2CA_DisconnectLECocReq(l2cap_cid);
    } else {
      L2CA_DisconnectReq(l2cap_cid);
      L2CA_DisconnectReq(l2cap_cid);
    }
    return;
    return;
  }
  }


+4 −0
Original line number Original line Diff line number Diff line
@@ -507,6 +507,8 @@ extern bool L2CA_ConnectCreditBasedRsp(const RawAddress& p_bd_addr, uint8_t id,
 ******************************************************************************/
 ******************************************************************************/
extern bool L2CA_DisconnectReq(uint16_t cid);
extern bool L2CA_DisconnectReq(uint16_t cid);


extern bool L2CA_DisconnectLECocReq(uint16_t cid);

/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         L2CA_DataWrite
 * Function         L2CA_DataWrite
@@ -521,6 +523,8 @@ extern bool L2CA_DisconnectReq(uint16_t cid);
 ******************************************************************************/
 ******************************************************************************/
extern uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data);
extern uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data);


extern uint8_t L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data);

// Given a local channel identifier, |lcid|, this function returns the bound
// Given a local channel identifier, |lcid|, this function returns the bound
// remote channel identifier, |rcid|. If
// remote channel identifier, |rcid|. If
// |lcid| is not known or is invalid, this function returns false and does not
// |lcid| is not known or is invalid, this function returns false and does not
+6 −0
Original line number Original line Diff line number Diff line
@@ -891,6 +891,8 @@ bool L2CA_DisconnectReq(uint16_t cid) {
  return (true);
  return (true);
}
}


bool L2CA_DisconnectLECocReq(uint16_t cid) { return L2CA_DisconnectReq(cid); }

bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) {
bool L2CA_GetRemoteCid(uint16_t lcid, uint16_t* rcid) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
  if (bluetooth::shim::is_gd_l2cap_enabled()) {
    return bluetooth::shim::L2CA_GetRemoteCid(lcid, rcid);
    return bluetooth::shim::L2CA_GetRemoteCid(lcid, rcid);
@@ -1457,6 +1459,10 @@ uint8_t L2CA_DataWrite(uint16_t cid, BT_HDR* p_data) {
  return l2c_data_write(cid, p_data, L2CAP_FLUSHABLE_CH_BASED);
  return l2c_data_write(cid, p_data, L2CAP_FLUSHABLE_CH_BASED);
}
}


uint8_t L2CA_LECocDataWrite(uint16_t cid, BT_HDR* p_data) {
  return L2CA_DataWrite(cid, p_data);
}

/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         L2CA_SetChnlFlushability
 * Function         L2CA_SetChnlFlushability