Skip to contentSkip to conversation

SDP registrations and UPF bug fixes

PATCH In review Brian Gix 2 participants 5 messages Feb 18, 2011 – Feb 19, 2011 Bluetooth drivers

lore
Share & tools
lore

Brian Gix

author
#0 lore raw

cover SDP registrations and UPF bug fixes

Patch 1: Modified per Andersons suggestions

Patch 2: Isolated two remaining UPF bug fixes.

--
Brian Gix
[email protected]
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum

author
#1 lore raw

PATCH 1/2 Add SDP registration of Primary GATT services

Add capability to register SDP record for Primary Services.

---
 attrib/example.c    |   24 ++++++++
 src/attrib-server.c |  157 +++++++++++++++++++++++++++++++++++++++------------
 src/attrib-server.h |    3 +-
 3 files changed, 147 insertions(+), 37 deletions(-)
attrib/example.c +24 -0
index 1911912..cd18168 100644
@@ -59,6 +59,8 @@
 #define FMT_KILOGRAM_UUID		0xA010
 #define FMT_HANGING_UUID		0xA011
 
+static GSList *sdp_handles = NULL;
+
 static int register_attributes(void)
 {
 	const char *desc_out_temp = "Outside Temperature";
@@ -75,6 +77,7 @@ static int register_attributes(void)
 		0xD4, 0x49, 0x11, 0x96, 0x31, 0xDE, 0xA8, 0xDC, 0x74, 0xEE,
 		0xFE };
 	uint8_t atval[256];
+	uint32_t handle;
 	uuid_t uuid;
 	int len;
 
@@ -101,6 +104,11 @@ static int register_attributes(void)
 	atval[1] = 0x00;
 	attrib_db_add(0x0111, &uuid, ATT_NONE, ATT_AUTHENTICATION, atval, 2);
 
+	/* Add an SDP record for the above service */
+	handle = attrib_create_sdp(0x0100, "Battery State Service");
+	if (handle)
+		sdp_handles = g_slist_prepend(sdp_handles, GUINT_TO_POINTER(handle));
+
 	/* Thermometer: primary service definition */
 	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
 	att_put_u16(THERM_HUMIDITY_SVC_UUID, &atval[0]);
@@ -173,6 +181,11 @@ static int register_attributes(void)
 	strncpy((char *) atval, desc_out_hum, len);
 	attrib_db_add(0x0214, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, len);
 
+	/* Add an SDP record for the above service */
+	handle = attrib_create_sdp(0x0200, "Thermometer");
+	if (handle)
+		sdp_handles = g_slist_prepend(sdp_handles, GUINT_TO_POINTER(handle));
+
 	/* Secondary Service: Manufacturer Service */
 	sdp_uuid16_create(&uuid, GATT_SND_SVC_UUID);
 	att_put_u16(MANUFACTURER_SVC_UUID, &atval[0]);
@@ -299,6 +312,11 @@ static int register_attributes(void)
 	strncpy((char *) atval, desc_weight, len);
 	attrib_db_add(0x0685, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, len);
 
+	/* Add an SDP record for the above service */
+	handle = attrib_create_sdp(0x0680, "Weight Service");
+	if (handle)
+		sdp_handles = g_slist_prepend(sdp_handles, GUINT_TO_POINTER(handle));
+
 	return 0;
 }
 
@@ -309,4 +327,10 @@ int server_example_init(void)
 
 void server_example_exit(void)
 {
+	while (sdp_handles) {
+		uint32_t handle = GPOINTER_TO_UINT(sdp_handles->data);
+
+		attrib_free_sdp(handle);
+		sdp_handles = g_slist_remove(sdp_handles, sdp_handles->data);
+	}
 }
src/attrib-server.c +121 -36

229 lines not on this page · raw message

src/attrib-server.h +2 -1
index 252700f..ecd695c 100644
@@ -30,5 +30,6 @@ int attrib_db_add(uint16_t handle, uuid_t *uuid, int read_reqs, int write_reqs,
 int attrib_db_update(uint16_t handle, uuid_t *uuid, const uint8_t *value,
 								int len);
 int attrib_db_del(uint16_t handle);
-
 int attrib_gap_set(uint16_t uuid, const uint8_t *value, int len);
+uint32_t attrib_create_sdp(uint16_t handle, const char *name);
+void attrib_free_sdp(uint32_t sdp_handle);
Signature · 6 lines
1.7.1
--
Brian Gix
[email protected]
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
#2 lore raw

Re: [PATCH 1/2] Add SDP registration of Primary GATT services

Hi Brian,

Quoted 6 lines · Brian Gix

Add capability to register SDP record for Primary Services.

---
 attrib/example.c    |   24 ++++++++
 src/attrib-server.c |  157 +++++++++++++++++++++++++++++++++++++++------------
 src/attrib-server.h |    3 +-
 3 files changed, 147 insertions(+), 37 deletions(-)

This patch has been pushed upstream. Thanks.

Johan

author
#3 lore raw

PATCH 2/2 Fix bugs found at UPF38 - Las Vegas

In reply to Brian Gix

Example Included Service Attribute missing UUID16 field. MTU Exchange not bounded by actual size required not to crash.

---
 attrib/example.c    |    3 ++-
 src/attrib-server.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)
attrib/example.c +2 -1
index cd18168..395650a 100644
@@ -124,7 +124,8 @@ static int register_attributes(void)
 	/* Thermometer: Include */
 	att_put_u16(0x0550, &atval[0]);
 	att_put_u16(0x0568, &atval[2]);
-	attrib_db_add(0x0202, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 4);
+	att_put_u16(VENDOR_SPECIFIC_SVC_UUID, &atval[4]);
+	attrib_db_add(0x0202, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 6);
 
 	/* Thermometer: temperature characteristic */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
src/attrib-server.c +1 -1
index 6966ad0..4285f6e 100644
@@ -639,7 +639,7 @@ static uint16_t write_value(struct gatt_channel *channel, uint16_t handle,
 static uint16_t mtu_exchange(struct gatt_channel *channel, uint16_t mtu,
 		uint8_t *pdu, int len)
 {
-	channel->mtu = MIN(mtu, ATT_MAX_MTU);
+	channel->mtu = MIN(mtu, channel->mtu);
 
 	return enc_mtu_resp(channel->mtu, pdu, len);
 }
Signature · 6 lines
1.7.1
--
Brian Gix
[email protected]
Employee of Qualcomm Innovation Center, Inc.
Qualcomm Innovation Center, Inc. is a member of Code Aurora Forum
#4 lore raw

Re: [PATCH 2/2] Fix bugs found at UPF38 - Las Vegas

Hi Brian,

Quoted 6 lines · Brian Gix

Example Included Service Attribute missing UUID16 field. MTU Exchange not bounded by actual size required not to crash.

---
 attrib/example.c    |    3 ++-
 src/attrib-server.c |    2 +-
 2 files changed, 3 insertions(+), 2 deletions(-)

Even though these are some quite trivial changes, you essentially have to independent fixes here and they should therefore be in two separate patches. Also make sure that the summary line of each patch gives at least some idea of what is being fixed. The way you formulated it now just tells us that "something" found at UPF38 was fixed.

Johan

P.S. I think you can stop adding extra people to CC in your patch submissions. --to [email protected] should be enough.