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

Commit e08d30d5 authored by TreeHugger Robot's avatar TreeHugger Robot Committed by Android (Google) Code Review
Browse files

Merge "GATT: fix 32 bit UUID handling" into pi-dev

parents f295bb38 d4d55b51
Loading
Loading
Loading
Loading
+5 −5
Original line number Diff line number Diff line
@@ -148,12 +148,12 @@ static tGATT_STATUS gatts_check_attr_readability(const tGATT_ATTR& attr,
 *
 * Description      Utility function to read an attribute value.
 *
 * Parameter        p_attr: pointer to the attribute to read.
 * Parameter        attr16: pointer to the attribute to read.
 *                  offset: read offset.
 *                  p_value: output parameter to carry out the attribute value.
 *                  p_len: output parameter to carry out the attribute length.
 *                  p_data: output parameter to carry out the attribute value.
 *                  read_long: this is a read blob request.
 *                  mtu: MTU
 *                  p_len: output parameter to carry out the attribute length.
 *                   sec_flag: current link security status.
 *                  key_size: encryption key size.
 *
@@ -182,7 +182,7 @@ static tGATT_STATUS read_attr_value(tGATT_ATTR& attr16, uint16_t offset,
  uint16_t uuid16 = attr16.uuid.As16Bit();

  if (uuid16 == GATT_UUID_PRI_SERVICE || uuid16 == GATT_UUID_SEC_SERVICE) {
    *p_len = attr16.p_value->uuid.GetShortestRepresentationSize();
    *p_len = gatt_build_uuid_to_stream_len(attr16.p_value->uuid);
    if (mtu < *p_len) return GATT_NO_RESOURCES;

    gatt_build_uuid_to_stream(&p, attr16.p_value->uuid);
+1 −0
Original line number Diff line number Diff line
@@ -436,6 +436,7 @@ extern uint32_t gatt_add_sdp_record(const bluetooth::Uuid& uuid,
                                    uint16_t start_hdl, uint16_t end_hdl);
extern bool gatt_parse_uuid_from_cmd(bluetooth::Uuid* p_uuid, uint16_t len,
                                     uint8_t** p_data);
extern uint8_t gatt_build_uuid_to_stream_len(const bluetooth::Uuid& uuid);
extern uint8_t gatt_build_uuid_to_stream(uint8_t** p_dst,
                                         const bluetooth::Uuid& uuid);
extern void gatt_sr_get_sec_info(const RawAddress& rem_bda,
+1 −1
Original line number Diff line number Diff line
@@ -467,7 +467,7 @@ static tGATT_STATUS gatt_build_primary_service_rsp(
    if (!p_uuid) continue;

    if (op_code == GATT_REQ_READ_BY_GRP_TYPE)
      handle_len = 4 + p_uuid->GetShortestRepresentationSize();
      handle_len = 4 + gatt_build_uuid_to_stream_len(*p_uuid);

    /* get the length byte in the repsonse */
    if (p_msg->offset == 0) {
+8 −0
Original line number Diff line number Diff line
@@ -454,6 +454,14 @@ tGATT_TCB* gatt_allocate_tcb_by_bdaddr(const RawAddress& bda,
  return NULL;
}

/** gatt_build_uuid_to_stream will convert 32bit UUIDs to 128bit. This function
 * will return lenght required to build uuid, either |UUID:kNumBytes16| or
 * |UUID::kNumBytes128| */
uint8_t gatt_build_uuid_to_stream_len(const Uuid& uuid) {
  size_t len = uuid.GetShortestRepresentationSize();
  return len == Uuid::kNumBytes32 ? Uuid::kNumBytes128 : len;
}

/** Add UUID into stream. Returns UUID length. */
uint8_t gatt_build_uuid_to_stream(uint8_t** p_dst, const Uuid& uuid) {
  uint8_t* p = *p_dst;