return GATT_INTERNAL_ERROR;
}
- el->attribute_handle =
- gatts_add_characteristic(list.svc_db, el->permissions, el->properties,
- el->extended_properties, uuid);
+ el->attribute_handle = gatts_add_characteristic(
+ list.svc_db, el->permissions, el->properties, uuid);
+
+ // add characteristic extended properties descriptor if needed
+ if (el->properties & GATT_CHAR_PROP_BIT_EXT_PROP) {
+ gatts_add_char_ext_prop_descr(list.svc_db, el->extended_properties);
+ }
+
} else if (el->type == BTGATT_DB_DESCRIPTOR) {
if (is_gatt_attr_type(uuid)) {
LOG(ERROR) << __func__
******************************************************************************/
uint16_t gatts_add_characteristic(tGATT_SVC_DB& db, tGATT_PERM perm,
tGATT_CHAR_PROP property,
- uint16_t extended_properties,
const Uuid& char_uuid) {
Uuid uuid = Uuid::From16Bit(GATT_UUID_CHAR_DECLARE);
char_decl.p_value->char_decl.char_val_handle = char_val.handle;
char_val.gatt_type = BTGATT_DB_CHARACTERISTIC;
- if (property & GATT_CHAR_PROP_BIT_EXT_PROP) {
- Uuid char_ext_prop_uuid = Uuid::From16Bit(GATT_UUID_CHAR_EXT_PROP);
- tGATT_ATTR& char_ext_prop =
- allocate_attr_in_db(db, char_ext_prop_uuid, GATT_PERM_READ);
- char_ext_prop.p_value.reset(new tGATT_ATTR_VALUE);
- char_ext_prop.p_value->char_ext_prop = extended_properties;
- char_ext_prop.gatt_type = BTGATT_DB_DESCRIPTOR;
- }
-
return char_val.handle;
}
/*******************************************************************************
*
+ * Function gatts_add_char_ext_prop_descr
+ *
+ * Description add a characteristics extended properties descriptor.
+ *
+ * Parameter db: database pointer.
+ * extended_properties: characteristic descriptors values.
+ *
+ * Returns Status of the operation.
+ *
+ ******************************************************************************/
+uint16_t gatts_add_char_ext_prop_descr(
+ tGATT_SVC_DB& db, uint16_t extended_properties) {
+ Uuid descr_uuid = Uuid::From16Bit(GATT_UUID_CHAR_EXT_PROP);
+
+ VLOG(1) << StringPrintf("gatts_add_char_ext_prop_descr uuid=%s",
+ descr_uuid.ToString().c_str());
+
+ tGATT_ATTR& char_dscptr = allocate_attr_in_db(db, descr_uuid, GATT_PERM_READ);
+ char_dscptr.gatt_type = BTGATT_DB_DESCRIPTOR;
+ char_dscptr.p_value.reset(new tGATT_ATTR_VALUE);
+ char_dscptr.p_value->char_ext_prop = extended_properties;
+
+ return char_dscptr.handle;
+}
+
+/*******************************************************************************
+ *
* Function gatts_add_char_descr
*
* Description This function add a characteristics descriptor.
const bluetooth::Uuid& service);
extern uint16_t gatts_add_characteristic(tGATT_SVC_DB& db, tGATT_PERM perm,
tGATT_CHAR_PROP property,
- uint16_t extended_properties,
const bluetooth::Uuid& char_uuid);
+extern uint16_t gatts_add_char_ext_prop_descr(tGATT_SVC_DB& db,
+ uint16_t extended_properties);
extern uint16_t gatts_add_char_descr(tGATT_SVC_DB& db, tGATT_PERM perm,
const bluetooth::Uuid& dscp_uuid);
extern tGATT_STATUS gatts_db_read_attr_value_by_type(