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

Commit 276ff7a0 authored by Archie Pusaka's avatar Archie Pusaka Committed by Archie Pusaka
Browse files

Remove DIS server related code

Nothing accesses these code, so remove them.

Bug: 357011645
Test: m -j
Flag: EXEMPT, dead code removal
Change-Id: I677d790a87766685baf6c9956113b19e5641254f
parent 63c95dd5
Loading
Loading
Loading
Loading
+0 −20
Original line number Original line Diff line number Diff line
@@ -132,26 +132,6 @@ typedef union {
 ******************************************************************************/
 ******************************************************************************/
tGATT_STATUS srvc_eng_init(void);
tGATT_STATUS srvc_eng_init(void);


/*****************************************************************************
 *  DIS Server Function
 ****************************************************************************/

/*******************************************************************************
 *
 * Function         DIS_SrInit
 *
 * Description      Initializa the Device Information Service Server.
 *
 ******************************************************************************/
tDIS_STATUS DIS_SrInit(tDIS_ATTR_MASK dis_attr_mask);
/*******************************************************************************
 *
 * Function         DIS_SrUpdate
 *
 * Description      Update the DIS server attribute values
 *
 ******************************************************************************/
tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR* p_info);
/*****************************************************************************
/*****************************************************************************
 *  DIS Client Function
 *  DIS Client Function
 ****************************************************************************/
 ****************************************************************************/
+8 −189
Original line number Original line Diff line number Diff line
@@ -32,30 +32,9 @@
#include "types/bluetooth/uuid.h"
#include "types/bluetooth/uuid.h"
#include "types/raw_address.h"
#include "types/raw_address.h"


using base::StringPrintf;
using namespace bluetooth;
using namespace bluetooth;


#define DIS_MAX_NUM_INC_SVR 0
static const uint16_t dis_attr_uuid[] = {
#define DIS_MAX_CHAR_NUM 9
#define DIS_MAX_ATTR_NUM (DIS_MAX_CHAR_NUM * 2 + DIS_MAX_NUM_INC_SVR + 1)

#ifndef DIS_ATTR_DB_SIZE
#define DIS_ATTR_DB_SIZE GATT_DB_MEM_SIZE(DIS_MAX_NUM_INC_SVR, DIS_MAX_CHAR_NUM, 0)
#endif

#define uint64_t_TO_STREAM(p, u64)   \
  {                                  \
    *(p)++ = (uint8_t)(u64);         \
    *(p)++ = (uint8_t)((u64) >> 8);  \
    *(p)++ = (uint8_t)((u64) >> 16); \
    *(p)++ = (uint8_t)((u64) >> 24); \
    *(p)++ = (uint8_t)((u64) >> 32); \
    *(p)++ = (uint8_t)((u64) >> 40); \
    *(p)++ = (uint8_t)((u64) >> 48); \
    *(p)++ = (uint8_t)((u64) >> 56); \
  }

static const uint16_t dis_attr_uuid[DIS_MAX_CHAR_NUM] = {
        GATT_UUID_SYSTEM_ID,      GATT_UUID_MODEL_NUMBER_STR, GATT_UUID_SERIAL_NUMBER_STR,
        GATT_UUID_SYSTEM_ID,      GATT_UUID_MODEL_NUMBER_STR, GATT_UUID_SERIAL_NUMBER_STR,
        GATT_UUID_FW_VERSION_STR, GATT_UUID_HW_VERSION_STR,   GATT_UUID_SW_VERSION_STR,
        GATT_UUID_FW_VERSION_STR, GATT_UUID_HW_VERSION_STR,   GATT_UUID_SW_VERSION_STR,
        GATT_UUID_MANU_NAME,      GATT_UUID_IEEE_DATA,        GATT_UUID_PNP_ID};
        GATT_UUID_MANU_NAME,      GATT_UUID_IEEE_DATA,        GATT_UUID_PNP_ID};
@@ -92,13 +71,7 @@ static tDIS_ATTR_MASK dis_uuid_to_attr(uint16_t uuid) {
 *
 *
 *   validate a handle to be a DIS attribute handle or not.
 *   validate a handle to be a DIS attribute handle or not.
 ******************************************************************************/
 ******************************************************************************/
bool dis_valid_handle_range(uint16_t handle) {
bool dis_valid_handle_range(uint16_t /* handle */) { return false; }
  if (handle >= dis_cb.service_handle && handle <= dis_cb.max_handle) {
    return true;
  } else {
    return false;
  }
}
/*******************************************************************************
/*******************************************************************************
 *   dis_write_attr_value
 *   dis_write_attr_value
 *
 *
@@ -111,71 +84,11 @@ uint8_t dis_write_attr_value(tGATT_WRITE_REQ* /* p_data */, tGATT_STATUS* p_stat
/*******************************************************************************
/*******************************************************************************
 *   DIS Attributes Database Server Request callback
 *   DIS Attributes Database Server Request callback
 ******************************************************************************/
 ******************************************************************************/
uint8_t dis_read_attr_value(uint8_t /* clcb_idx */, uint16_t handle, tGATT_VALUE* p_value,
uint8_t dis_read_attr_value(uint8_t /* clcb_idx */, uint16_t /* handle */,
                            bool is_long, tGATT_STATUS* p_status) {
                            tGATT_VALUE* /* p_value */, bool /* is_long */,
  tDIS_DB_ENTRY* p_db_attr = dis_cb.dis_attr;
                            tGATT_STATUS* p_status) {
  uint8_t *p = p_value->value, i, *pp;
  *p_status = GATT_NOT_FOUND;
  uint16_t offset = p_value->offset;
  return SRVC_ACT_RSP;
  uint8_t act = SRVC_ACT_RSP;
  tGATT_STATUS st = GATT_NOT_FOUND;

  for (i = 0; i < DIS_MAX_CHAR_NUM; i++, p_db_attr++) {
    if (handle == p_db_attr->handle) {
      if ((p_db_attr->uuid == GATT_UUID_PNP_ID || p_db_attr->uuid == GATT_UUID_SYSTEM_ID) &&
          is_long) {
        st = GATT_NOT_LONG;
        break;
      }
      st = GATT_SUCCESS;

      switch (p_db_attr->uuid) {
        case GATT_UUID_MANU_NAME:
        case GATT_UUID_MODEL_NUMBER_STR:
        case GATT_UUID_SERIAL_NUMBER_STR:
        case GATT_UUID_FW_VERSION_STR:
        case GATT_UUID_HW_VERSION_STR:
        case GATT_UUID_SW_VERSION_STR:
        case GATT_UUID_IEEE_DATA:
          pp = dis_cb.dis_value.data_string[p_db_attr->uuid - GATT_UUID_MODEL_NUMBER_STR];
          if (pp != NULL) {
            if (strlen((char*)pp) > GATT_MAX_ATTR_LEN) {
              p_value->len = GATT_MAX_ATTR_LEN;
            } else {
              p_value->len = (uint16_t)strlen((char*)pp);
            }
          } else {
            p_value->len = 0;
          }

          if (offset > p_value->len) {
            st = GATT_INVALID_OFFSET;
            break;
          } else {
            p_value->len -= offset;
            pp += offset;
            ARRAY_TO_STREAM(p, pp, p_value->len);
            log::verbose("GATT_UUID_MANU_NAME len=0x{:x}", p_value->len);
          }
          break;

        case GATT_UUID_SYSTEM_ID:
          uint64_t_TO_STREAM(p, dis_cb.dis_value.system_id); /* int_min */
          p_value->len = DIS_SYSTEM_ID_SIZE;
          break;

        case GATT_UUID_PNP_ID:
          UINT8_TO_STREAM(p, dis_cb.dis_value.pnp_id.vendor_id_src);
          UINT16_TO_STREAM(p, dis_cb.dis_value.pnp_id.vendor_id);
          UINT16_TO_STREAM(p, dis_cb.dis_value.pnp_id.product_id);
          UINT16_TO_STREAM(p, dis_cb.dis_value.pnp_id.product_version);
          p_value->len = DIS_PNP_ID_SIZE;
          break;
      }
      break;
    }
  }
  *p_status = st;
  return act;
}
}


/*******************************************************************************
/*******************************************************************************
@@ -220,7 +133,7 @@ bool dis_gatt_c_read_dis_req(uint16_t conn_id) {
  param.service.e_handle = 0xFFFF;
  param.service.e_handle = 0xFFFF;
  param.service.auth_req = 0;
  param.service.auth_req = 0;


  while (dis_cb.dis_read_uuid_idx < DIS_MAX_CHAR_NUM) {
  while (dis_cb.dis_read_uuid_idx < (sizeof(dis_attr_uuid) / sizeof(dis_attr_uuid[0]))) {
    if (dis_uuid_to_attr(dis_attr_uuid[dis_cb.dis_read_uuid_idx]) & dis_cb.request_mask) {
    if (dis_uuid_to_attr(dis_attr_uuid[dis_cb.dis_read_uuid_idx]) & dis_cb.request_mask) {
      param.service.uuid = bluetooth::Uuid::From16Bit(dis_attr_uuid[dis_cb.dis_read_uuid_idx]);
      param.service.uuid = bluetooth::Uuid::From16Bit(dis_attr_uuid[dis_cb.dis_read_uuid_idx]);


@@ -318,100 +231,6 @@ void dis_c_cmpl_cback(tSRVC_CLCB* p_clcb, tGATTC_OPTYPE op, tGATT_STATUS status,
  dis_gatt_c_read_dis_req(conn_id);
  dis_gatt_c_read_dis_req(conn_id);
}
}


/*******************************************************************************
 *
 * Function         DIS_SrInit
 *
 * Description      Initialize the Device Information Service Server.
 *
 ******************************************************************************/
tDIS_STATUS DIS_SrInit(tDIS_ATTR_MASK dis_attr_mask) {
  tGATT_STATUS status;

  if (dis_cb.enabled) {
    log::error("DIS already initialized");
    return DIS_SUCCESS;
  }

  memset(&dis_cb, 0, sizeof(tDIS_CB));

  btgatt_db_element_t service[DIS_MAX_ATTR_NUM] = {};

  bluetooth::Uuid svc_uuid = bluetooth::Uuid::From16Bit(UUID_SERVCLASS_DEVICE_INFO);
  service[0].type = BTGATT_DB_PRIMARY_SERVICE;
  service[0].uuid = svc_uuid;

  for (int i = 0; dis_attr_mask != 0 && i < DIS_MAX_CHAR_NUM; i++) {
    dis_cb.dis_attr[i].uuid = dis_attr_uuid[i];

    bluetooth::Uuid char_uuid = bluetooth::Uuid::From16Bit(dis_cb.dis_attr[i].uuid);
    /* index 0 is service, so characteristics start from 1 */
    service[i + 1].type = BTGATT_DB_CHARACTERISTIC;
    service[i + 1].uuid = char_uuid;
    service[i + 1].properties = GATT_CHAR_PROP_BIT_READ;
    service[i + 1].permissions = GATT_PERM_READ;

    dis_attr_mask >>= 1;
  }

  /* Add a GAP service */
  status = GATTS_AddService(srvc_eng_cb.gatt_if, service,
                            sizeof(service) / sizeof(btgatt_db_element_t));
  if (status != GATT_SERVICE_STARTED) {
    log::error("Can not create service, DIS_Init failed!");
    return GATT_ERROR;
  }

  dis_cb.service_handle = service[0].attribute_handle;
  dis_cb.max_handle = dis_cb.service_handle + DIS_MAX_ATTR_NUM;

  for (int i = 0; i < DIS_MAX_CHAR_NUM; i++) {
    dis_cb.dis_attr[i].handle = service[i + 1].attribute_handle;

    log::verbose("handle of new attribute 0x{:04x} = {}", dis_cb.dis_attr[i].uuid,
                 dis_cb.dis_attr[i].handle);
  }

  dis_cb.enabled = true;
  return (tDIS_STATUS)status;
}
/*******************************************************************************
 *
 * Function         DIS_SrUpdate
 *
 * Description      Update the DIS server attribute values
 *
 ******************************************************************************/
tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT dis_attr_bit, tDIS_ATTR* p_info) {
  uint8_t i = 1;
  tDIS_STATUS st = DIS_SUCCESS;

  if (dis_attr_bit & DIS_ATTR_SYS_ID_BIT) {
    dis_cb.dis_value.system_id = p_info->system_id;
  } else if (dis_attr_bit & DIS_ATTR_PNP_ID_BIT) {
    dis_cb.dis_value.pnp_id.vendor_id = p_info->pnp_id.vendor_id;
    dis_cb.dis_value.pnp_id.vendor_id_src = p_info->pnp_id.vendor_id_src;
    dis_cb.dis_value.pnp_id.product_id = p_info->pnp_id.product_id;
    dis_cb.dis_value.pnp_id.product_version = p_info->pnp_id.product_version;
  } else {
    st = DIS_ILLEGAL_PARAM;

    while (dis_attr_bit && i < (DIS_MAX_CHAR_NUM - 1)) {
      if (dis_attr_bit & (uint16_t)(1 << i)) {
        osi_free(dis_cb.dis_value.data_string[i - 1]);
        dis_cb.dis_value.data_string[i - 1] = (uint8_t*)osi_malloc(p_info->data_str.len + 1);
        memcpy(dis_cb.dis_value.data_string[i - 1], p_info->data_str.p_data, p_info->data_str.len);
        dis_cb.dis_value.data_string[i - 1][p_info->data_str.len] =
                0; /* make sure null terminate */
        st = DIS_SUCCESS;

        break;
      }
      i++;
    }
  }
  return st;
}
/*******************************************************************************
/*******************************************************************************
 *
 *
 * Function         DIS_ReadDISInfo
 * Function         DIS_ReadDISInfo
+0 −17
Original line number Original line Diff line number Diff line
@@ -24,29 +24,12 @@
#include "srvc_api.h"
#include "srvc_api.h"
#include "srvc_eng_int.h"
#include "srvc_eng_int.h"


#define DIS_MAX_CHAR_NUM 9

typedef struct {
  uint16_t uuid;
  uint16_t handle;
} tDIS_DB_ENTRY;

#define DIS_SYSTEM_ID_SIZE 8
#define DIS_SYSTEM_ID_SIZE 8
#define DIS_PNP_ID_SIZE 7
#define DIS_PNP_ID_SIZE 7


typedef struct {
typedef struct {
  tDIS_DB_ENTRY dis_attr[DIS_MAX_CHAR_NUM];
  tDIS_VALUE dis_value;

  tDIS_READ_CBACK* p_read_dis_cback;
  tDIS_READ_CBACK* p_read_dis_cback;

  uint16_t service_handle;
  uint16_t max_handle;

  bool enabled;

  uint8_t dis_read_uuid_idx;
  uint8_t dis_read_uuid_idx;

  tDIS_ATTR_MASK request_mask;
  tDIS_ATTR_MASK request_mask;
} tDIS_CB;
} tDIS_CB;


+0 −8
Original line number Original line Diff line number Diff line
@@ -39,14 +39,6 @@ bool dis_valid_handle_range(uint16_t /* handle */) {
  inc_func_call_count(__func__);
  inc_func_call_count(__func__);
  return false;
  return false;
}
}
tDIS_STATUS DIS_SrInit(tDIS_ATTR_MASK /* dis_attr_mask */) {
  inc_func_call_count(__func__);
  return 0;
}
tDIS_STATUS DIS_SrUpdate(tDIS_ATTR_BIT /* dis_attr_bit */, tDIS_ATTR* /* p_info */) {
  inc_func_call_count(__func__);
  return 0;
}
uint8_t dis_read_attr_value(uint8_t /* clcb_idx */, uint16_t /* handle */,
uint8_t dis_read_attr_value(uint8_t /* clcb_idx */, uint16_t /* handle */,
                            tGATT_VALUE* /* p_value */, bool /* is_long */,
                            tGATT_VALUE* /* p_value */, bool /* is_long */,
                            tGATT_STATUS* /* p_status */) {
                            tGATT_STATUS* /* p_status */) {