All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH BlueZ 1/3] shared/util: Add bt_uuid128_to_str
@ 2021-05-18 18:39 Luiz Augusto von Dentz
  2021-05-18 18:39 ` [PATCH BlueZ 2/3] shared/util: Decode BlueZ experimental UUIDs Luiz Augusto von Dentz
                   ` (2 more replies)
  0 siblings, 3 replies; 5+ messages in thread
From: Luiz Augusto von Dentz @ 2021-05-18 18:39 UTC (permalink / raw)
  To: linux-bluetooth

From: Luiz Augusto von Dentz <luiz.von.dentz@intel.com>

This adds bt_uuid128_to_str which can be used to convert UUID 128 bit
binary format into string.
---
 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 9c2054211..7fb1c01dc 100644
--- a/src/shared/util.c
+++ b/src/shared/util.c
@@ -1042,6 +1042,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 d6de55885..9920b7f76 100644
--- 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.30.2


^ permalink raw reply related	[flat|nested] 5+ messages in thread

end of thread, other threads:[~2021-05-19 18:02 UTC | newest]

Thread overview: 5+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2021-05-18 18:39 [PATCH BlueZ 1/3] shared/util: Add bt_uuid128_to_str Luiz Augusto von Dentz
2021-05-18 18:39 ` [PATCH BlueZ 2/3] shared/util: Decode BlueZ experimental UUIDs Luiz Augusto von Dentz
2021-05-18 18:39 ` [PATCH BlueZ 3/3] btmon: Use bt_uuid128_to_str when printing UUIDs of 128 bits Luiz Augusto von Dentz
2021-05-18 19:04 ` [BlueZ,1/3] shared/util: Add bt_uuid128_to_str bluez.test.bot
2021-05-19 18:01   ` Luiz Augusto von Dentz

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.