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

Commit ef617c38 authored by Nitin Shivpure's avatar Nitin Shivpure Committed by Myles Watson
Browse files

L2CAP: Handle no idle timeout (0xFFFF)

Precondition:
1. DUT acts as GATT server.
2. Remote acts as Gatt Client

Use case:
1. Remote device starts BLE scan
2. Remote device connects to DUT
3. Remote device keeps on sending notifications to DUT

Expected result:
Connection should be active after 18 hours

Observed Result:
Connection is dropped after 18 hours due to l2c_link_timeout.

Root Cause:
L2CAP is not properly handling no idle timeout(0xFFFF) and 65535000 ms
timer gets started after BLE connection, leading to connection getting dropped
after 18 hours.

Fix:
If there is no L2CAP dynamic ccb and no idle timeout is configured for
GATT or any other fixed  channel, then cancel existing LCB timer.

Test: No BLE disconnection seen after 18 hours

Bug: 112249120
Change-Id: I58766564cf62efb7af0869035115459bae37c558
parent 73a19a85
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -54,6 +54,8 @@ constexpr uint16_t L2CAP_LE_CREDIT_THRESHOLD = 0x0040;
static_assert(L2CAP_LE_CREDIT_THRESHOLD < L2CAP_LE_CREDIT_DEFAULT,
              "Threshold must be smaller then default credits");

#define L2CAP_NO_IDLE_TIMEOUT 0xFFFF

/*
 * Timeout values (in milliseconds).
 */
+6 −0
Original line number Diff line number Diff line
@@ -2617,6 +2617,12 @@ void l2cu_no_dynamic_ccbs(tL2C_LCB* p_lcb) {
  for (xx = 0; xx < L2CAP_NUM_FIXED_CHNLS; xx++) {
    if ((p_lcb->p_fixed_ccbs[xx] != NULL) &&
        (p_lcb->p_fixed_ccbs[xx]->fixed_chnl_idle_tout * 1000 > timeout_ms)) {

      if (p_lcb->p_fixed_ccbs[xx]->fixed_chnl_idle_tout == L2CAP_NO_IDLE_TIMEOUT) {
         L2CAP_TRACE_DEBUG("%s NO IDLE timeout set for fixed cid 0x%04x", __func__,
            p_lcb->p_fixed_ccbs[xx]->local_cid);
         start_timeout = false;
      }
      timeout_ms = p_lcb->p_fixed_ccbs[xx]->fixed_chnl_idle_tout * 1000;
    }
  }