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

Commit 7976c59b authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

has_client: Improve subscribtion to control point

As per specification we should register for notification when EATT is
used and indication if EATT is NOT used. This is bit odd as having
support and being able to connect, and maintaing connection are
different things.
To be on the save side we would like to register to both - notification
and indication and let server to decide what it is sent (based on the
bearer).

With this patch, we register to anything what servers allow dispite
EATT tracking.

This will also help PTS testing

Bug: 238171211
Test: atest BluetoothInstrumentationTests
Test: PTS
Tag: #feature
Merged-In: I7c30278de00e3e75c6ecd9b6c55258b7eef92fe9
Change-Id: I7c30278de00e3e75c6ecd9b6c55258b7eef92fe9
(cherry picked from commit 967aa140)
parent b649882a
Loading
Loading
Loading
Loading
+15 −5
Original line number Diff line number Diff line
@@ -39,6 +39,7 @@
#include "gap_api.h"
#include "gatt_api.h"
#include "has_types.h"
#include "osi/include/log.h"
#include "osi/include/osi.h"
#include "osi/include/properties.h"

@@ -1538,9 +1539,22 @@ class HasClientImpl : public HasClient {
                     << ": no HAS Control Point CCC descriptor found!";
          return false;
        }
        uint8_t ccc_val = 0;
        if (charac.properties & GATT_CHAR_PROP_BIT_NOTIFY)
          ccc_val |= GATT_CHAR_CLIENT_CONFIG_NOTIFICATION;

        if (charac.properties & GATT_CHAR_PROP_BIT_INDICATE)
          ccc_val |= GATT_CHAR_CLIENT_CONFIG_INDICTION;

        if (ccc_val == 0) {
          LOG_ERROR("Invalid properties for the control point 0x%02x",
                    charac.properties);
          return false;
        }

        device->cp_ccc_handle = ccc_handle;
        device->cp_handle = charac.value_handle;
        device->cp_ccc_val = ccc_val;
      } else if (charac.uuid == kUuidHearingAidFeatures) {
        /* Find the optional CCC descriptor */
        uint16_t ccc_handle =
@@ -1653,13 +1667,9 @@ class HasClientImpl : public HasClient {
     * mandatory active preset index notifications.
     */
    if (device->SupportsPresets()) {
      uint16_t ccc_val = gatt_profile_get_eatt_support(device->addr)
                             ? GATT_CHAR_CLIENT_CONFIG_INDICTION |
                                   GATT_CHAR_CLIENT_CONFIG_NOTIFICATION
                             : GATT_CHAR_CLIENT_CONFIG_INDICTION;
      SubscribeForNotifications(device->conn_id, device->addr,
                                device->cp_handle, device->cp_ccc_handle,
                                ccc_val);
                                device->cp_ccc_val);

      /* Get all the presets */
      CpReadAllPresetsOperation(HasCtpOp(
+1 −0
Original line number Diff line number Diff line
@@ -170,6 +170,7 @@ class HasDevice : public GattServiceDevice {
  uint16_t active_preset_ccc_handle = GAP_INVALID_HANDLE;
  uint16_t cp_handle = GAP_INVALID_HANDLE;
  uint16_t cp_ccc_handle = GAP_INVALID_HANDLE;
  uint8_t cp_ccc_val = 0;
  uint16_t features_handle = GAP_INVALID_HANDLE;
  uint16_t features_ccc_handle = GAP_INVALID_HANDLE;