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

Commit be431b03 authored by Łukasz Rymanowski's avatar Łukasz Rymanowski
Browse files

eatt: Add upper tester to trigger Read Multiple Value Len Req

Android does not expose such API but to the used, but when EATT is
supported, Android needs to pass Read Multiple Value Len Request
qualification test. Note: It does not force us to expose this as API.

Upper tester is added for this purpose and should be enabled with
GATT_UPPER_TESTER_MULT_VARIABLE_LENGTH_READ

Bug: 236083555
Test: atest BluetoothInstrumentationTests
Test: GATT/CL/GAT/BV-03-C
Tag: #stability
Merged-In: Id56757ba7d374f309615b8149ad37a7760e46651
Change-Id: Id56757ba7d374f309615b8149ad37a7760e46651
(cherry picked from commit 1b7644b504adb928a20df1e6c9405ab34eb7a468)
parent 15abef1a
Loading
Loading
Loading
Loading
+5 −0
Original line number Diff line number Diff line
@@ -555,6 +555,11 @@
#ifndef GATT_UPPER_TESTER_MULT_VARIABLE_LENGTH_NOTIF
#define GATT_UPPER_TESTER_MULT_VARIABLE_LENGTH_NOTIF FALSE
#endif

/* Used only for GATT Multiple Variable Length READ PTS tests */
#ifndef GATT_UPPER_TESTER_MULT_VARIABLE_LENGTH_READ
#define GATT_UPPER_TESTER_MULT_VARIABLE_LENGTH_READ FALSE
#endif
/******************************************************************************
 *
 * SMP
+32 −0
Original line number Diff line number Diff line
@@ -820,6 +820,10 @@ tGATT_STATUS GATTC_Read(uint16_t conn_id, tGATT_READ_TYPE type,
  uint8_t tcb_idx = GATT_GET_TCB_IDX(conn_id);
  tGATT_TCB* p_tcb = gatt_get_tcb_by_idx(tcb_idx);
  tGATT_REG* p_reg = gatt_get_regcb(gatt_if);
#if (GATT_UPPER_TESTER_MULT_VARIABLE_LENGTH_READ == TRUE)
  static uint16_t cached_read_handle;
  static int cached_tcb_idx = -1;
#endif

  VLOG(1) << __func__ << ": conn_id=" << loghex(conn_id)
          << ", type=" << loghex(type);
@@ -863,6 +867,34 @@ tGATT_STATUS GATTC_Read(uint16_t conn_id, tGATT_READ_TYPE type,
      break;
    }
    case GATT_READ_BY_HANDLE:
#if (GATT_UPPER_TESTER_MULT_VARIABLE_LENGTH_READ == TRUE)
      LOG_INFO("Upper tester: Handle read 0x%04x", p_read->by_handle.handle);
      /* This is upper tester for the  Multi Read stuff as this is mandatory for
       * EATT, even Android is not making use of this operation :/ */
      if (cached_tcb_idx < 0) {
        cached_tcb_idx = tcb_idx;
        LOG_INFO("Upper tester: Read multiple  - first read");
        cached_read_handle = p_read->by_handle.handle;
      } else if (cached_tcb_idx == tcb_idx) {
        LOG_INFO("Upper tester: Read multiple  - second read");
        cached_tcb_idx = -1;
        tGATT_READ_MULTI* p_read_multi =
            (tGATT_READ_MULTI*)osi_malloc(sizeof(tGATT_READ_MULTI));
        p_read_multi->num_handles = 2;
        p_read_multi->handles[0] = cached_read_handle;
        p_read_multi->handles[1] = p_read->by_handle.handle;
        p_read_multi->variable_len = true;

        p_clcb->s_handle = 0;
        p_clcb->op_subtype = GATT_READ_MULTIPLE_VAR_LEN;
        p_clcb->p_attr_buf = (uint8_t*)p_read_multi;
        p_clcb->cid = gatt_tcb_get_att_cid(*p_tcb, true /* eatt support */);

        break;
      }

      FALLTHROUGH_INTENDED;
#endif
    case GATT_READ_PARTIAL:
      p_clcb->uuid = Uuid::kEmpty;
      p_clcb->s_handle = p_read->by_handle.handle;
+5 −0
Original line number Diff line number Diff line
@@ -200,6 +200,11 @@ void gatt_act_read(tGATT_CLCB* p_clcb, uint16_t offset) {
      memcpy(&msg.read_multi, p_clcb->p_attr_buf, sizeof(tGATT_READ_MULTI));
      break;

    case GATT_READ_MULTIPLE_VAR_LEN:
      op_code = GATT_REQ_READ_MULTI_VAR;
      memcpy(&msg.read_multi, p_clcb->p_attr_buf, sizeof(tGATT_READ_MULTI));
      break;

    case GATT_READ_INC_SRV_UUID128:
      op_code = GATT_REQ_READ;
      msg.handle = p_clcb->s_handle;
+1 −0
Original line number Diff line number Diff line
@@ -518,6 +518,7 @@ enum {
  GATT_READ_BY_TYPE = 1,
  GATT_READ_BY_HANDLE,
  GATT_READ_MULTIPLE,
  GATT_READ_MULTIPLE_VAR_LEN,
  GATT_READ_CHAR_VALUE,
  GATT_READ_PARTIAL,
  GATT_READ_MAX