Skip to contentSkip to conversation

32-bit UUID support for GATT Attribute Type

PATCH New Sudha Bheemanna 1 participant 2 messages Apr 8, 2014 1 message not in the archive Bluetooth drivers

lore
Share & tools
lore

A message that is not in the archive (sent off-list or not yet received): [email protected]

#1 lore raw

PATCH v2 1/1 32-bit UUID support for GATT Attribute Type

1>The BT core4.0 spec supports only 16-bit and 128-bit uuids for the attribute
type in GATT devices.
2>The BT core 4.1 spec specifies the support for 32-bit uuid for Attribute
type in GATT devices.

This patch provides the code changes for 32-bit uuid for attribute type in GATT client role.

---
 attrib/att.c  |   12 ++++++++++++
 attrib/gatt.c |   11 +++++++++++
 2 files changed, 23 insertions(+)
attrib/att.c +12 -0
index 8e9c06d..2225255 100644
@@ -42,6 +42,8 @@ static inline void put_uuid_le(const bt_uuid_t *src, void *dst)
 {
 	if (src->type == BT_UUID16)
 		put_le16(src->value.u16, dst);
+	else if (src->type == BT_UUID32)
+		put_le32(src->value.u32, dst);
 	else
 		/* Convert from 128-bit BE to LE */
 		bswap_128(&src->value.u128, dst);
@@ -134,6 +136,8 @@ static void get_uuid(uint8_t type, const void *val, bt_uuid_t *uuid)
 {
 	if (type == BT_UUID16)
 		bt_uuid16_create(uuid, get_le16(val));
+	else if (type == BT_UUID32)
+		bt_uuid32_create(uuid, get_le32(val));
 	else {
 		uint128_t u128;
 
@@ -153,6 +157,8 @@ uint16_t enc_read_by_grp_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
 
 	if (uuid->type == BT_UUID16)
 		uuid_len = 2;
+	else if (uuid->type == BT_UUID32)
+		uuid_len = 4;
 	else if (uuid->type == BT_UUID128)
 		uuid_len = 16;
 	else
@@ -187,6 +193,8 @@ uint16_t dec_read_by_grp_req(const uint8_t *pdu, size_t len, uint16_t *start,
 
 	if (len == (min_len + 2))
 		type = BT_UUID16;
+	else if (len == (min_len + 4))
+		type = BT_UUID32;
 	else if (len == (min_len + 16))
 		type = BT_UUID128;
 	else
@@ -398,6 +406,8 @@ uint16_t enc_read_by_type_req(uint16_t start, uint16_t end, bt_uuid_t *uuid,
 
 	if (uuid->type == BT_UUID16)
 		uuid_len = 2;
+	else if (uuid->type == BT_UUID32)
+		uuid_len = 4;
 	else if (uuid->type == BT_UUID128)
 		uuid_len = 16;
 	else
@@ -429,6 +439,8 @@ uint16_t dec_read_by_type_req(const uint8_t *pdu, size_t len, uint16_t *start,
 
 	if (len == (min_len + 2))
 		type = BT_UUID16;
+	if (len == (min_len + 4))
+		type = BT_UUID32;
 	else if (len == (min_len + 16))
 		type = BT_UUID128;
 	else
attrib/gatt.c +11 -0
index 49cd1a3..bb2330a 100644
@@ -143,6 +143,8 @@ static void put_uuid_le(const bt_uuid_t *uuid, void *dst)
 {
 	if (uuid->type == BT_UUID16)
 		put_le16(uuid->value.u16, dst);
+	else if (uuid->type == BT_UUID32)
+		put_le32(uuid->value.u32, dst);
 	else
 		/* Convert from 128-bit BE to LE */
 		bswap_128(&uuid->value.u128, dst);
@@ -155,6 +157,11 @@ static void get_uuid128(uint8_t type, const void *val, bt_uuid_t *uuid)
 
 		bt_uuid16_create(&uuid16, get_le16(val));
 		bt_uuid_to_uuid128(&uuid16, uuid);
+	} else if (type == BT_UUID32) {
+		bt_uuid_t uuid32;
+
+		bt_uuid32_create(&uuid32, get_le32(val));
+		bt_uuid_to_uuid128(&uuid32, uuid);
 	} else {
 		uint128_t u128;
 
@@ -256,6 +263,8 @@ static void primary_all_cb(guint8 status, const guint8 *ipdu, guint16 iplen,
 
 	if (list->len == 6)
 		type = BT_UUID16;
+	else if (list->len == 8)
+		type = BT_UUID32;
 	else if (list->len == 20)
 		type = BT_UUID128;
 	else {
@@ -519,6 +528,8 @@ static void char_discovered_cb(guint8 status, const guint8 *ipdu, guint16 iplen,
 
 	if (list->len == 7)
 		type = BT_UUID16;
+	else if (list->len == 9)
+		type = BT_UUID32;
 	else
 		type = BT_UUID128;
 
Signature · 1 line
1.7.9.5
#2 lore raw

PATCH v2 1/1 32Bit UUID support for GATT Server Attribute Type

In reply to a message not in the archive

1>The BT core4.0 spec supports only 16-bit and 128-bit uuids for the attribute
type in GATT server devices.
2>The BT core 4.1 spec specifies the support for 32-bit uuid for Attribute
type.

This patch provides the code changes for 32-bit uuid for attribute type in GATT server role.

---
 attrib/gatt-service.c |   18 +++++--
 src/attrib-server.c   |  125 ++++++++++++++++++++++++++++++++++++++++++++-----
 2 files changed, 127 insertions(+), 16 deletions(-)
attrib/gatt-service.c +14 -4
index 874552b..ce26335 100644
@@ -60,6 +60,8 @@ static inline void put_uuid_le(const bt_uuid_t *src, void *dst)
 {
 	if (src->type == BT_UUID16)
 		put_le16(src->value.u16, dst);
+	if (src->type == BT_UUID32)
+		put_le32(src->value.u32, dst);
 	else
 		/* Convert from 128-bit BE to LE */
 		bswap_128(&src->value.u128, dst);
@@ -195,8 +197,8 @@ static gboolean add_characteristic(struct btd_adapter *adapter,
 	uint8_t atval[ATT_MAX_VALUE_LEN];
 	GSList *l;
 
-	if ((info->uuid.type != BT_UUID16 && info->uuid.type != BT_UUID128) ||
-								!info->props) {
+	if (info->uuid.type != BT_UUID16 && info->uuid.type != BT_UUID32
+			&& info->uuid.type != BT_UUID128 && !info->props) {
 		error("Characteristic UUID or properties are missing");
 		return FALSE;
 	}
@@ -229,10 +231,17 @@ static gboolean add_characteristic(struct btd_adapter *adapter,
 	}
 
 	/* characteristic declaration */
-	bt_uuid16_create(&bt_uuid, GATT_CHARAC_UUID);
 	atval[0] = info->props;
 	put_le16(h + 1, &atval[1]);
+
+	if (info->uuid.type == BT_UUID16)
+		bt_uuid16_create(&bt_uuid, GATT_CHARAC_UUID);
+
+	else if (info->uuid.type == BT_UUID32)
+		bt_uuid32_create(&bt_uuid, GATT_CHARAC_UUID);
+
 	put_uuid_le(&info->uuid, &atval[3]);
+
 	if (attrib_db_add(adapter, h++, &bt_uuid, ATT_NONE, ATT_NOT_PERMITTED,
 				atval, 3 + info->uuid.type / 8) == NULL)
 		return FALSE;
@@ -311,7 +320,8 @@ gboolean gatt_service_add(struct btd_adapter *adapter, uint16_t uuid,
 
 	bt_uuid_to_string(svc_uuid, uuidstr, MAX_LEN_UUID_STR);
 
-	if (svc_uuid->type != BT_UUID16 && svc_uuid->type != BT_UUID128) {
+	if (svc_uuid->type != BT_UUID16 && svc_uuid->type != BT_UUID32
+			&&	svc_uuid->type != BT_UUID128) {
 		error("Invalid service uuid: %s", uuidstr);
 		return FALSE;
 	}
src/attrib-server.c +113 -12

203 lines not on this page · raw message

Signature · 1 line
1.7.9.5