From: Luiz Augusto von Dentz <luiz.von.dentz@xxxxxxxxx> Handle 0 should be allocate on the next handle just as gatt_db_add_service. --- src/shared/gatt-db.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index d28301ac4..b0ab2994e 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -525,9 +525,12 @@ struct gatt_db_attribute *gatt_db_insert_service(struct gatt_db *db, after = NULL; - if (!db || handle < 1) + if (!db) return NULL; + if (!handle) + handle = db->next_handle; + if (num_handles < 1 || (handle + num_handles - 1) > UINT16_MAX) return NULL; @@ -585,8 +588,7 @@ struct gatt_db_attribute *gatt_db_add_service(struct gatt_db *db, bool primary, uint16_t num_handles) { - return gatt_db_insert_service(db, db->next_handle, uuid, primary, - num_handles); + return gatt_db_insert_service(db, 0, uuid, primary, num_handles); } unsigned int gatt_db_register(struct gatt_db *db, -- 2.17.2