From d35ed8a85754d5b8b3a078765e8ace96473ba39d Mon Sep 17 00:00:00 2001 From: Szymon Janc Date: Sat, 26 Apr 2014 14:40:00 +0200 Subject: [PATCH] shared/gatt: Fix uuid_to_le function 32-bit UUIDs must be converted to 128-bit before being transmitted. --- src/shared/gatt-db.c | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index 5d732e8d5..20fb63176 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -125,19 +125,16 @@ static struct gatt_db_attribute *new_attribute(const bt_uuid_t *type, static int uuid_to_le(const bt_uuid_t *uuid, uint8_t *dst) { - switch (uuid->type) { - case BT_UUID16: + bt_uuid_t uuid128; + + if (uuid->type == BT_UUID16) { put_le16(uuid->value.u16, dst); - break; - case BT_UUID32: - put_le32(uuid->value.u32, dst); - break; - default: - bswap_128(&uuid->value.u128, dst); - break; + return bt_uuid_len(uuid); } - return bt_uuid_len(uuid); + bt_uuid_to_uuid128(uuid, &uuid128); + bswap_128(&uuid128.value.u128, dst); + return bt_uuid_len(&uuid128); } uint16_t gatt_db_add_service(struct gatt_db *db, const bt_uuid_t *uuid, -- 2.47.3