Loading system/bta/gatt/bta_gattc_cache.cc +6 −0 Original line number Diff line number Diff line Loading @@ -710,12 +710,18 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV* p_srvc_cb, charac.value_handle, 0 /* s_handle */, 0 /* e_handle */, charac.value_handle, charac.uuid, charac.properties); btgatt_db_element_t* characteristic = curr_db_attr; curr_db_attr++; for (const Descriptor& desc : charac.descriptors) { bta_gattc_fill_gatt_db_el( curr_db_attr, BTGATT_DB_DESCRIPTOR, desc.handle, 0 /* s_handle */, 0 /* e_handle */, desc.handle, desc.uuid, 0 /* property */); if (desc.uuid == Uuid::From16Bit(GATT_UUID_CHAR_EXT_PROP)) { characteristic->extended_properties = desc.characteristic_extended_properties; } curr_db_attr++; } } Loading system/include/hardware/bt_common_types.h +2 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ typedef struct { * the characteristic. */ uint8_t properties; uint16_t extended_properties; uint16_t permissions; } btgatt_db_element_t; Loading system/stack/gatt/gatt_api.cc +10 −5 Original line number Diff line number Diff line Loading @@ -106,12 +106,16 @@ static uint16_t compute_service_size(btgatt_db_element_t* service, int count) { if (el->type == BTGATT_DB_PRIMARY_SERVICE || el->type == BTGATT_DB_SECONDARY_SERVICE || el->type == BTGATT_DB_DESCRIPTOR || el->type == BTGATT_DB_INCLUDED_SERVICE) el->type == BTGATT_DB_INCLUDED_SERVICE) { db_size += 1; else if (el->type == BTGATT_DB_CHARACTERISTIC) } else if (el->type == BTGATT_DB_CHARACTERISTIC) { db_size += 2; else // if present, Characteristic Extended Properties takes one handle if (el->properties & GATT_CHAR_PROP_BIT_EXT_PROP) db_size++; } else { LOG(ERROR) << __func__ << ": Unknown element type: " << el->type; } return db_size; } Loading Loading @@ -235,8 +239,9 @@ uint16_t GATTS_AddService(tGATT_IF gatt_if, btgatt_db_element_t* service, return GATT_INTERNAL_ERROR; } el->attribute_handle = gatts_add_characteristic( list.svc_db, el->permissions, el->properties, uuid); el->attribute_handle = gatts_add_characteristic(list.svc_db, el->permissions, el->properties, el->extended_properties, uuid); } else if (el->type == BTGATT_DB_DESCRIPTOR) { if (is_gatt_attr_type(uuid)) { LOG(ERROR) << __func__ Loading system/stack/gatt/gatt_db.cc +24 −4 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ void gatts_init_service_db(tGATT_SVC_DB& db, const Uuid& service_uuid, Uuid uuid = Uuid::From16Bit(is_pri ? GATT_UUID_PRI_SERVICE : GATT_UUID_SEC_SERVICE); tGATT_ATTR& attr = allocate_attr_in_db(db, uuid, GATT_PERM_READ); attr.p_value.reset((tGATT_ATTR_VALUE*)(new Uuid)); attr.p_value.reset(new tGATT_ATTR_VALUE); attr.p_value->uuid = service_uuid; } Loading Loading @@ -231,7 +231,15 @@ static tGATT_STATUS read_attr_value(tGATT_ATTR& attr16, uint16_t offset, return GATT_SUCCESS; } /* characteristic description or characteristic value (again) */ if (uuid16 == GATT_UUID_CHAR_EXT_PROP) { uint16_t char_ext_prop = attr16.p_value->char_ext_prop; *p_len = 2; UINT16_TO_STREAM(p, char_ext_prop); *p_data = p; return GATT_SUCCESS; } /* characteristic descriptor or characteristic value (again) */ return GATT_PENDING; } Loading Loading @@ -342,7 +350,7 @@ uint16_t gatts_add_included_service(tGATT_SVC_DB& db, uint16_t s_handle, tGATT_ATTR& attr = allocate_attr_in_db(db, uuid, GATT_PERM_READ); attr.p_value.reset((tGATT_ATTR_VALUE*)(new tGATT_INCL_SRVC)); attr.p_value.reset(new tGATT_ATTR_VALUE); attr.p_value->incl_handle.s_handle = s_handle; attr.p_value->incl_handle.e_handle = e_handle; attr.p_value->incl_handle.service_type = service; Loading @@ -360,6 +368,7 @@ uint16_t gatts_add_included_service(tGATT_SVC_DB& db, uint16_t s_handle, * Parameter db: database. * perm: permission (authentication and key size requirements) * property: property of the characteristic. * extended_properties: characteristic extended properties. * p_char: characteristic value information. * * Returns Status of te operation. Loading @@ -367,6 +376,7 @@ uint16_t gatts_add_included_service(tGATT_SVC_DB& db, uint16_t s_handle, ******************************************************************************/ 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); Loading @@ -376,10 +386,20 @@ uint16_t gatts_add_characteristic(tGATT_SVC_DB& db, tGATT_PERM perm, tGATT_ATTR& char_decl = allocate_attr_in_db(db, uuid, GATT_PERM_READ); tGATT_ATTR& char_val = allocate_attr_in_db(db, char_uuid, perm); char_decl.p_value.reset((tGATT_ATTR_VALUE*)(new tGATT_CHAR_DECL)); char_decl.p_value.reset(new tGATT_ATTR_VALUE); char_decl.p_value->char_decl.property = property; 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; } Loading system/stack/gatt/gatt_int.h +2 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,7 @@ typedef union { bluetooth::Uuid uuid; /* service declaration */ tGATT_CHAR_DECL char_decl; /* characteristic declaration */ tGATT_INCL_SRVC incl_handle; /* included service */ uint16_t char_ext_prop; /* Characteristic Extended Properties */ } tGATT_ATTR_VALUE; /* Attribute UUID type Loading Loading @@ -594,6 +595,7 @@ extern uint16_t gatts_add_included_service(tGATT_SVC_DB& db, uint16_t s_handle, 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_descr(tGATT_SVC_DB& db, tGATT_PERM perm, const bluetooth::Uuid& dscp_uuid); Loading Loading
system/bta/gatt/bta_gattc_cache.cc +6 −0 Original line number Diff line number Diff line Loading @@ -710,12 +710,18 @@ static void bta_gattc_get_gatt_db_impl(tBTA_GATTC_SERV* p_srvc_cb, charac.value_handle, 0 /* s_handle */, 0 /* e_handle */, charac.value_handle, charac.uuid, charac.properties); btgatt_db_element_t* characteristic = curr_db_attr; curr_db_attr++; for (const Descriptor& desc : charac.descriptors) { bta_gattc_fill_gatt_db_el( curr_db_attr, BTGATT_DB_DESCRIPTOR, desc.handle, 0 /* s_handle */, 0 /* e_handle */, desc.handle, desc.uuid, 0 /* property */); if (desc.uuid == Uuid::From16Bit(GATT_UUID_CHAR_EXT_PROP)) { characteristic->extended_properties = desc.characteristic_extended_properties; } curr_db_attr++; } } Loading
system/include/hardware/bt_common_types.h +2 −0 Original line number Diff line number Diff line Loading @@ -71,6 +71,8 @@ typedef struct { * the characteristic. */ uint8_t properties; uint16_t extended_properties; uint16_t permissions; } btgatt_db_element_t; Loading
system/stack/gatt/gatt_api.cc +10 −5 Original line number Diff line number Diff line Loading @@ -106,12 +106,16 @@ static uint16_t compute_service_size(btgatt_db_element_t* service, int count) { if (el->type == BTGATT_DB_PRIMARY_SERVICE || el->type == BTGATT_DB_SECONDARY_SERVICE || el->type == BTGATT_DB_DESCRIPTOR || el->type == BTGATT_DB_INCLUDED_SERVICE) el->type == BTGATT_DB_INCLUDED_SERVICE) { db_size += 1; else if (el->type == BTGATT_DB_CHARACTERISTIC) } else if (el->type == BTGATT_DB_CHARACTERISTIC) { db_size += 2; else // if present, Characteristic Extended Properties takes one handle if (el->properties & GATT_CHAR_PROP_BIT_EXT_PROP) db_size++; } else { LOG(ERROR) << __func__ << ": Unknown element type: " << el->type; } return db_size; } Loading Loading @@ -235,8 +239,9 @@ uint16_t GATTS_AddService(tGATT_IF gatt_if, btgatt_db_element_t* service, return GATT_INTERNAL_ERROR; } el->attribute_handle = gatts_add_characteristic( list.svc_db, el->permissions, el->properties, uuid); el->attribute_handle = gatts_add_characteristic(list.svc_db, el->permissions, el->properties, el->extended_properties, uuid); } else if (el->type == BTGATT_DB_DESCRIPTOR) { if (is_gatt_attr_type(uuid)) { LOG(ERROR) << __func__ Loading
system/stack/gatt/gatt_db.cc +24 −4 Original line number Diff line number Diff line Loading @@ -66,7 +66,7 @@ void gatts_init_service_db(tGATT_SVC_DB& db, const Uuid& service_uuid, Uuid uuid = Uuid::From16Bit(is_pri ? GATT_UUID_PRI_SERVICE : GATT_UUID_SEC_SERVICE); tGATT_ATTR& attr = allocate_attr_in_db(db, uuid, GATT_PERM_READ); attr.p_value.reset((tGATT_ATTR_VALUE*)(new Uuid)); attr.p_value.reset(new tGATT_ATTR_VALUE); attr.p_value->uuid = service_uuid; } Loading Loading @@ -231,7 +231,15 @@ static tGATT_STATUS read_attr_value(tGATT_ATTR& attr16, uint16_t offset, return GATT_SUCCESS; } /* characteristic description or characteristic value (again) */ if (uuid16 == GATT_UUID_CHAR_EXT_PROP) { uint16_t char_ext_prop = attr16.p_value->char_ext_prop; *p_len = 2; UINT16_TO_STREAM(p, char_ext_prop); *p_data = p; return GATT_SUCCESS; } /* characteristic descriptor or characteristic value (again) */ return GATT_PENDING; } Loading Loading @@ -342,7 +350,7 @@ uint16_t gatts_add_included_service(tGATT_SVC_DB& db, uint16_t s_handle, tGATT_ATTR& attr = allocate_attr_in_db(db, uuid, GATT_PERM_READ); attr.p_value.reset((tGATT_ATTR_VALUE*)(new tGATT_INCL_SRVC)); attr.p_value.reset(new tGATT_ATTR_VALUE); attr.p_value->incl_handle.s_handle = s_handle; attr.p_value->incl_handle.e_handle = e_handle; attr.p_value->incl_handle.service_type = service; Loading @@ -360,6 +368,7 @@ uint16_t gatts_add_included_service(tGATT_SVC_DB& db, uint16_t s_handle, * Parameter db: database. * perm: permission (authentication and key size requirements) * property: property of the characteristic. * extended_properties: characteristic extended properties. * p_char: characteristic value information. * * Returns Status of te operation. Loading @@ -367,6 +376,7 @@ uint16_t gatts_add_included_service(tGATT_SVC_DB& db, uint16_t s_handle, ******************************************************************************/ 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); Loading @@ -376,10 +386,20 @@ uint16_t gatts_add_characteristic(tGATT_SVC_DB& db, tGATT_PERM perm, tGATT_ATTR& char_decl = allocate_attr_in_db(db, uuid, GATT_PERM_READ); tGATT_ATTR& char_val = allocate_attr_in_db(db, char_uuid, perm); char_decl.p_value.reset((tGATT_ATTR_VALUE*)(new tGATT_CHAR_DECL)); char_decl.p_value.reset(new tGATT_ATTR_VALUE); char_decl.p_value->char_decl.property = property; 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; } Loading
system/stack/gatt/gatt_int.h +2 −0 Original line number Diff line number Diff line Loading @@ -156,6 +156,7 @@ typedef union { bluetooth::Uuid uuid; /* service declaration */ tGATT_CHAR_DECL char_decl; /* characteristic declaration */ tGATT_INCL_SRVC incl_handle; /* included service */ uint16_t char_ext_prop; /* Characteristic Extended Properties */ } tGATT_ATTR_VALUE; /* Attribute UUID type Loading Loading @@ -594,6 +595,7 @@ extern uint16_t gatts_add_included_service(tGATT_SVC_DB& db, uint16_t s_handle, 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_descr(tGATT_SVC_DB& db, tGATT_PERM perm, const bluetooth::Uuid& dscp_uuid); Loading