bool gatt_db_attribute_get_service_data(const struct gatt_db_attribute *attrib, uint16_t *start_handle, uint16_t *end_handle, bool *primary, bt_uuid_t *uuid) { struct gatt_db_service *service; struct gatt_db_attribute *decl; if (!attrib) return false; service = attrib->service; decl = service->attributes[0]; gatt_db_service_get_handles(service, start_handle, end_handle); if (primary) *primary = bt_uuid_cmp(&decl->uuid, &secondary_service_uuid); if (!uuid) return true; /* * The service declaration attribute value is the 16 or 128 bit service * UUID. */ return le_to_uuid(decl->value, decl->value_len, uuid); }
bool gatt_db_attribute_get_char_data(const struct gatt_db_attribute *attrib, uint16_t *handle, uint16_t *value_handle, uint8_t *properties, uint16_t *ext_prop, bt_uuid_t *uuid) { if (!attrib) return false; if (bt_uuid_cmp(&characteristic_uuid, &attrib->uuid)) return false; /* * Characteristic declaration value: * 1 octet: Characteristic properties * 2 octets: Characteristic value handle * 2 or 16 octets: characteristic UUID */ if (!attrib->value || (attrib->value_len != 5 && attrib->value_len != 19)) return false; if (handle) *handle = attrib->handle; if (properties) *properties = attrib->value[0]; if (ext_prop) *ext_prop = get_char_extended_prop(attrib); if (value_handle) *value_handle = get_le16(attrib->value + 1); if (!uuid) return true; return le_to_uuid(attrib->value + 3, attrib->value_len - 3, uuid); }