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

Commit 27a9748e authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

gatt: Fix handling GATT connect timeout

When there is a timeout on create connection, all gatt clients
interested in the connection shall be notified about TIMEOUT.

With the recent changes improving creating multiple connections, there
is no TCB allocated for each connection we want to create. Therefore,
there is no unique conn_id allocated for the p_clcb.

That means, when notifing about timeout, stack shell not generate
CONN_ID using tcb_idx=0 as it could be already use by other device.
This could lead to situation that GATT thinks that other connected
devices just got disconnected.

Bug: 335816515
Bug: 325595120
Test: atest pts-bot:GATT
Change-Id: Ibf013b196caf38d46e81d6b97610060872697176
parent 6460734d
Loading
Loading
Loading
Loading
+3 −6
Original line number Diff line number Diff line
@@ -1751,16 +1751,13 @@ static void gatt_le_disconnect_complete_notify_user(const RawAddress& bda,
                                                    tGATT_DISCONN_REASON reason,
                                                    tBT_TRANSPORT transport) {
  tGATT_TCB* p_tcb = gatt_find_tcb_by_addr(bda, transport);
  uint8_t tcb_idx = 0;

  if (p_tcb) {
    tcb_idx = p_tcb->tcb_idx;
  }

  for (uint8_t i = 0; i < GATT_MAX_APPS; i++) {
    tGATT_REG* p_reg = &gatt_cb.cl_rcb[i];
    if (p_reg->in_use && p_reg->app_cb.p_conn_cb) {
      uint16_t conn_id = GATT_CREATE_CONN_ID(tcb_idx, p_reg->gatt_if);
      uint16_t conn_id =
          p_tcb ? GATT_CREATE_CONN_ID(p_tcb->tcb_idx, p_reg->gatt_if)
                : GATT_INVALID_CONN_ID;
      (*p_reg->app_cb.p_conn_cb)(p_reg->gatt_if, bda, conn_id,
                                 kGattDisconnected, reason, transport);
    }