This patch refactor le_to_uuid function and convert 32-bit uuid value to 128-bit value then swap bytes. This is needed since we don't handle 32-bit uuid values. --- src/shared/gatt-db.c | 26 +++++++++++++------------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/src/shared/gatt-db.c b/src/shared/gatt-db.c index f103c5a..295d6cc 100644 --- a/src/shared/gatt-db.c +++ b/src/shared/gatt-db.c @@ -337,25 +337,25 @@ bool gatt_db_isempty(struct gatt_db *db) static bool le_to_uuid(const uint8_t *src, size_t len, bt_uuid_t *uuid) { + bt_uuid_t uuid128, uuid32; uint128_t u128; - if (len == 2) { + switch (len) { + case 2: bt_uuid16_create(uuid, get_le16(src)); return true; - } - - if (len == 4) { - bt_uuid32_create(uuid, get_le32(src)); + case 4: + bt_uuid32_create(&uuid32, get_le32(src)); + bt_uuid_to_uuid128(&uuid32, &uuid128); + src = uuid128.value.u128.data; + /* Fallthrough */ + case 16: + bswap_128(src, &u128); + bt_uuid128_create(uuid, u128); return true; - } - - if (len != 16) + default: return false; - - bswap_128(src, &u128); - bt_uuid128_create(uuid, u128); - - return true; + } } static struct gatt_db_service *gatt_db_service_create(const bt_uuid_t *uuid, -- 2.1.0 -- To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in the body of a message to majordomo@xxxxxxxxxxxxxxx More majordomo info at http://vger.kernel.org/majordomo-info.html