From 963a6b00e69397cbed613b4a86a51f587a0bf624 Mon Sep 17 00:00:00 2001 From: Luiz Augusto von Dentz Date: Tue, 18 May 2021 11:04:25 -0700 Subject: [PATCH] shared/util: Add bt_uuid128_to_str This adds bt_uuid128_to_str which can be used to convert UUID 128 bit binary format into string. Signed-off-by: Anuj Jain Signed-off-by: Ayush Garg --- src/shared/util.c | 12 ++++++++++++ src/shared/util.h | 1 + 2 files changed, 13 insertions(+) diff --git a/src/shared/util.c b/src/shared/util.c index 369936f..3a85419 100755 --- a/src/shared/util.c +++ b/src/shared/util.c @@ -1041,6 +1041,18 @@ const char *bt_uuid32_to_str(uint32_t uuid) return "Unknown"; } +const char *bt_uuid128_to_str(const uint8_t uuid[16]) +{ + char uuidstr[37]; + + sprintf(uuidstr, "%8.8x-%4.4x-%4.4x-%4.4x-%8.8x%4.4x", + get_le32(&uuid[12]), get_le16(&uuid[10]), + get_le16(&uuid[8]), get_le16(&uuid[6]), + get_le32(&uuid[2]), get_le16(&uuid[0])); + + return bt_uuidstr_to_str(uuidstr); +} + const char *bt_uuidstr_to_str(const char *uuid) { uint32_t val; diff --git a/src/shared/util.h b/src/shared/util.h index d6de558..9920b7f 100755 --- a/src/shared/util.h +++ b/src/shared/util.h @@ -107,6 +107,7 @@ void util_clear_uid(unsigned int *bitmap, uint8_t id); const char *bt_uuid16_to_str(uint16_t uuid); const char *bt_uuid32_to_str(uint32_t uuid); +const char *bt_uuid128_to_str(const uint8_t uuid[16]); const char *bt_uuidstr_to_str(const char *uuid); const char *bt_appear_to_str(uint16_t appearance); -- 2.7.4