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

Commit 63ec7bf6 authored by IHLHO KIM's avatar IHLHO KIM Committed by Andre Eisenbach
Browse files

Fix the GATT server and HOGP disconnect

GATT server disconnect and HOGP disconnect are not working after the
following commit: bd9e1ef1.

‘BTA_GATTS_CancelOpen’ makes ‘gatt_update_app_hold_link_status’
return FALSE value. As a result, ‘BTA_GATTS_Close’ cannot disconnect
the link. The sequence has to be changed like GATT client.

And the above mentioned fix removed ‘found’ checking routine in
‘gatt_update_app_hold_link_status’.

It makes two app hold links with same gatt_if when HOGP is connected and
background connection is added. But HOGP disconnect removes only one held
link. So HOGP is never disconnected.

The ‘found’ checking routine has to be rolled back.

Test: manual
Change-Id: Ibea825b5cc844195f0cf4a30cbcca831880c9088
parent db12bf15
Loading
Loading
Loading
Loading
+7 −5
Original line number Diff line number Diff line
@@ -339,12 +339,14 @@ static bt_status_t btif_gatts_open(int server_if, const bt_bdaddr_t* bd_addr,
}

static void btif_gatts_close_impl(int server_if, BD_ADDR address, int conn_id) {
  // Cancel pending foreground/background connections
  // Close active connection
  if (conn_id != 0)
    BTA_GATTS_Close(conn_id);
  else
    BTA_GATTS_CancelOpen(server_if, address, true);
  BTA_GATTS_CancelOpen(server_if, address, false);

  // Close active connection
  if (conn_id != 0) BTA_GATTS_Close(conn_id);
  // Cancel pending background connections
  BTA_GATTS_CancelOpen(server_if, address, false);
}

static bt_status_t btif_gatts_close(int server_if, const bt_bdaddr_t* bd_addr,
+9 −1
Original line number Diff line number Diff line
@@ -253,11 +253,19 @@ bool gatt_disconnect(tGATT_TCB* p_tcb) {
 *
 * Description      Update the application use link status
 *
 * Returns          true if any modifications are made, false otherwise.
 * Returns          true if any modifications are made or
 *                  when it already exists, false otherwise.
 *
 ******************************************************************************/
bool gatt_update_app_hold_link_status(tGATT_IF gatt_if, tGATT_TCB* p_tcb,
                                      bool is_add) {
  for (int i = 0; i < GATT_MAX_APPS; i++) {
    if (p_tcb->app_hold_link[i] == gatt_if && is_add) {
      GATT_TRACE_DEBUG("%s: gatt_if %d already exists at idx %d", __func__, gatt_if, i);
      return true;
    }
  }

  for (int i = 0; i < GATT_MAX_APPS; i++) {
    if (p_tcb->app_hold_link[i] == 0 && is_add) {
      p_tcb->app_hold_link[i] = gatt_if;