linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH 1/3] Refactor example server to use att_put_u16()
@ 2011-01-07 20:12 Anderson Lizardo
  2011-01-07 20:12 ` [PATCH 2/3] Move GAP service registration to src/attrib-server.c Anderson Lizardo
                   ` (2 more replies)
  0 siblings, 3 replies; 4+ messages in thread
From: Anderson Lizardo @ 2011-01-07 20:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

The original code was written before att_put_u16() was implemented.
---
 attrib/example.c |  162 +++++++++++++++---------------------------------------
 1 files changed, 45 insertions(+), 117 deletions(-)

diff --git a/attrib/example.c b/attrib/example.c
index 6987fac..f28068a 100644
--- a/attrib/example.c
+++ b/attrib/example.c
@@ -78,23 +78,17 @@ static int register_attributes(void)
 	uint8_t atval[256];
 	uuid_t uuid;
 	int len;
-	uint16_t u16;
 
 	/* GAP service: primary service definition */
 	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
-	u16 = htons(GENERIC_ACCESS_PROFILE_ID);
-	atval[0] = u16 >> 8;
-	atval[1] = u16;
+	att_put_u16(GENERIC_ACCESS_PROFILE_ID, &atval[0]);
 	attrib_db_add(0x0001, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
 
 	/* GAP service: device name characteristic */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(GATT_CHARAC_DEVICE_NAME);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x06;
-	atval[2] = 0x00;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0006, &atval[1]);
+	att_put_u16(GATT_CHARAC_DEVICE_NAME, &atval[3]);
 	attrib_db_add(0x0004, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* GAP service: device name attribute */
@@ -105,19 +99,14 @@ static int register_attributes(void)
 
 	/* GATT service: primary service definition */
 	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
-	u16 = htons(GENERIC_ATTRIB_PROFILE_ID);
-	atval[0] = u16 >> 8;
-	atval[1] = u16;
+	att_put_u16(GENERIC_ATTRIB_PROFILE_ID, &atval[0]);
 	attrib_db_add(0x0010, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
 
 	/* GATT service: attributes opcodes characteristic */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(OPCODES_SUPPORTED_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x12;
-	atval[2] = 0x00;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0012, &atval[1]);
+	att_put_u16(OPCODES_SUPPORTED_UUID, &atval[3]);
 	attrib_db_add(0x0011, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* GATT service: attribute opcodes supported */
@@ -128,19 +117,14 @@ static int register_attributes(void)
 
 	/* Battery state service: primary service definition */
 	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
-	u16 = htons(BATTERY_STATE_SVC_UUID);
-	atval[0] = u16 >> 8;
-	atval[1] = u16;
+	att_put_u16(BATTERY_STATE_SVC_UUID, &atval[0]);
 	attrib_db_add(0x0100, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
 
 	/* Battery: battery state characteristic */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(BATTERY_STATE_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x10;
-	atval[2] = 0x01;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0110, &atval[1]);
+	att_put_u16(BATTERY_STATE_UUID, &atval[3]);
 	attrib_db_add(0x0106, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* Battery: battery state attribute */
@@ -156,37 +140,26 @@ static int register_attributes(void)
 
 	/* Thermometer: primary service definition */
 	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
-	u16 = htons(THERM_HUMIDITY_SVC_UUID);
-	atval[0] = u16 >> 8;
-	atval[1] = u16;
+	att_put_u16(THERM_HUMIDITY_SVC_UUID, &atval[0]);
 	attrib_db_add(0x0200, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
 
 	/* Thermometer: Include */
 	sdp_uuid16_create(&uuid, GATT_INCLUDE_UUID);
-	u16 = htons(MANUFACTURER_SVC_UUID);
-	atval[0] = 0x00;
-	atval[1] = 0x05;
-	atval[2] = 0x04;
-	atval[3] = 0x05;
-	atval[4] = u16 >> 8;
-	atval[5] = u16;
+	att_put_u16(0x0500, &atval[0]);
+	att_put_u16(0x0504, &atval[2]);
+	att_put_u16(MANUFACTURER_SVC_UUID, &atval[4]);
 	attrib_db_add(0x0201, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 6);
 
 	/* Thermometer: Include */
-	atval[0] = 0x50;
-	atval[1] = 0x05;
-	atval[2] = 0x68;
-	atval[3] = 0x05;
+	att_put_u16(0x0550, &atval[0]);
+	att_put_u16(0x0568, &atval[2]);
 	attrib_db_add(0x0202, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 4);
 
 	/* Thermometer: temperature characteristic */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(TEMPERATURE_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x04;
-	atval[2] = 0x02;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0204, &atval[1]);
+	att_put_u16(TEMPERATURE_UUID, &atval[3]);
 	attrib_db_add(0x0203, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* Thermometer: temperature characteristic value */
@@ -197,15 +170,11 @@ static int register_attributes(void)
 
 	/* Thermometer: temperature characteristic format */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_FMT_UUID);
-	u16 = htons(FMT_CELSIUS_UUID);
 	atval[0] = 0x0E;
 	atval[1] = 0xFE;
-	atval[2] = u16 >> 8;
-	atval[3] = u16;
+	att_put_u16(FMT_CELSIUS_UUID, &atval[2]);
 	atval[4] = 0x01;
-	u16 = htons(FMT_OUTSIDE_UUID);
-	atval[5] = u16 >> 8;
-	atval[6] = u16;
+	att_put_u16(FMT_OUTSIDE_UUID, &atval[5]);
 	attrib_db_add(0x0205, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 7);
 
 	/* Thermometer: characteristic user description */
@@ -216,12 +185,9 @@ static int register_attributes(void)
 
 	/* Thermometer: relative humidity characteristic */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(RELATIVE_HUMIDITY_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x12;
-	atval[2] = 0x02;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0212, &atval[1]);
+	att_put_u16(RELATIVE_HUMIDITY_UUID, &atval[3]);
 	attrib_db_add(0x0210, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* Thermometer: relative humidity value */
@@ -231,17 +197,11 @@ static int register_attributes(void)
 
 	/* Thermometer: relative humidity characteristic format */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_FMT_UUID);
-	u16 = htons(FMT_PERCENT_UUID);
 	atval[0] = 0x04;
 	atval[1] = 0x00;
-	atval[2] = u16 >> 8;
-	atval[3] = u16;
-	u16 = htons(BLUETOOTH_SIG_UUID);
-	atval[4] = u16 >> 8;
-	atval[5] = u16;
-	u16 = htons(FMT_OUTSIDE_UUID);
-	atval[6] = u16 >> 8;
-	atval[7] = u16;
+	att_put_u16(FMT_PERCENT_UUID, &atval[2]);
+	att_put_u16(BLUETOOTH_SIG_UUID, &atval[4]);
+	att_put_u16(FMT_OUTSIDE_UUID, &atval[6]);
 	attrib_db_add(0x0213, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 8);
 
 	/* Thermometer: characteristic user description */
@@ -252,19 +212,14 @@ static int register_attributes(void)
 
 	/* Secondary Service: Manufacturer Service */
 	sdp_uuid16_create(&uuid, GATT_SND_SVC_UUID);
-	u16 = htons(MANUFACTURER_SVC_UUID);
-	atval[0] = u16 >> 8;
-	atval[1] = u16;
+	att_put_u16(MANUFACTURER_SVC_UUID, &atval[0]);
 	attrib_db_add(0x0500, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
 
 	/* Manufacturer name characteristic definition */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(MANUFACTURER_NAME_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x02;
-	atval[2] = 0x05;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0502, &atval[1]);
+	att_put_u16(MANUFACTURER_NAME_UUID, &atval[3]);
 	attrib_db_add(0x0501, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* Manufacturer name characteristic value */
@@ -275,12 +230,9 @@ static int register_attributes(void)
 
 	/* Manufacturer serial number characteristic */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(MANUFACTURER_SERIAL_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x04;
-	atval[2] = 0x05;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0504, &atval[1]);
+	att_put_u16(MANUFACTURER_SERIAL_UUID, &atval[3]);
 	attrib_db_add(0x0503, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* Manufacturer serial number characteristic value */
@@ -291,36 +243,26 @@ static int register_attributes(void)
 
 	/* Secondary Service: Manufacturer Service */
 	sdp_uuid16_create(&uuid, GATT_SND_SVC_UUID);
-	u16 = htons(MANUFACTURER_SVC_UUID);
-	atval[0] = u16 >> 8;
-	atval[1] = u16;
+	att_put_u16(MANUFACTURER_SVC_UUID, &atval[0]);
 	attrib_db_add(0x0505, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
 
 	/* Manufacturer name characteristic definition */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(MANUFACTURER_NAME_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x07;
-	atval[2] = 0x05;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0507, &atval[1]);
+	att_put_u16(MANUFACTURER_NAME_UUID, &atval[3]);
 	attrib_db_add(0x0506, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* Secondary Service: Vendor Specific Service */
 	sdp_uuid16_create(&uuid, GATT_SND_SVC_UUID);
-	u16 = htons(VENDOR_SPECIFIC_SVC_UUID);
-	atval[0] = u16 >> 8;
-	atval[1] = u16;
+	att_put_u16(VENDOR_SPECIFIC_SVC_UUID, &atval[0]);
 	attrib_db_add(0x0550, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
 
 	/* Vendor Specific Type characteristic definition */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(VENDOR_SPECIFIC_TYPE_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x68;
-	atval[2] = 0x05;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0568, &atval[1]);
+	att_put_u16(VENDOR_SPECIFIC_TYPE_UUID, &atval[3]);
 	attrib_db_add(0x0560, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* Vendor Specific Type characteristic value */
@@ -341,12 +283,9 @@ static int register_attributes(void)
 
 	/* Characteristic: serial number */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	u16 = htons(MANUFACTURER_SERIAL_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x09;
-	atval[2] = 0x05;
-	atval[3] = u16 >> 8;
-	atval[4] = u16;
+	att_put_u16(0x0509, &atval[1]);
+	att_put_u16(MANUFACTURER_SERIAL_UUID, &atval[3]);
 	attrib_db_add(0x0508, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
 
 	/* Serial number characteristic value */
@@ -362,21 +301,16 @@ static int register_attributes(void)
 
 	/* Weight: include */
 	sdp_uuid16_create(&uuid, GATT_INCLUDE_UUID);
-	u16 = htons(MANUFACTURER_SVC_UUID);
-	atval[0] = 0x05;
-	atval[1] = 0x05;
-	atval[2] = 0x09;
-	atval[3] = 0x05;
-	atval[4] = u16 >> 8;
-	atval[5] = u16;
+	att_put_u16(0x0505, &atval[0]);
+	att_put_u16(0x0509, &atval[2]);
+	att_put_u16(MANUFACTURER_SVC_UUID, &atval[4]);
 	attrib_db_add(0x0681, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 6);
 
 	/* Weight: characteristic */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
 	atval[0] = ATT_CHAR_PROPER_READ;
-	atval[1] = 0x83;
-	atval[2] = 0x06;
-	memcpy(atval + 3, char_weight_uuid, 16);
+	att_put_u16(0x0683, &atval[1]);
+	memcpy(&atval[3], char_weight_uuid, 16);
 	attrib_db_add(0x0682, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 19);
 
 	/* Weight: characteristic value */
@@ -389,17 +323,11 @@ static int register_attributes(void)
 
 	/* Weight: characteristic format */
 	sdp_uuid16_create(&uuid, GATT_CHARAC_FMT_UUID);
-	u16 = htons(FMT_KILOGRAM_UUID);
 	atval[0] = 0x08;
 	atval[1] = 0xFD;
-	atval[2] = u16 >> 8;
-	atval[3] = u16;
-	u16 = htons(BLUETOOTH_SIG_UUID);
-	atval[4] = u16 >> 8;
-	atval[5] = u16;
-	u16 = htons(FMT_HANGING_UUID);
-	atval[6] = u16 >> 8;
-	atval[7] = u16;
+	att_put_u16(FMT_KILOGRAM_UUID, &atval[2]);
+	att_put_u16(BLUETOOTH_SIG_UUID, &atval[4]);
+	att_put_u16(FMT_HANGING_UUID, &atval[6]);
 	attrib_db_add(0x0684, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 8);
 
 	/* Weight: characteristic user description */
-- 
1.7.0.4


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

* [PATCH 2/3] Move GAP service registration to src/attrib-server.c
  2011-01-07 20:12 [PATCH 1/3] Refactor example server to use att_put_u16() Anderson Lizardo
@ 2011-01-07 20:12 ` Anderson Lizardo
  2011-01-07 20:12 ` [PATCH 3/3] Move GATT service to attribute server core Anderson Lizardo
  2011-01-07 20:29 ` [PATCH 1/3] Refactor example server to use att_put_u16() Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Anderson Lizardo @ 2011-01-07 20:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

GAP service shall be registered only once, so it makes sense to move it
to the core attribute server code.

The GAP "Device Name" characteristic was always "Example Device" on the
example server. This has been changed to use the Name attribute from
main.conf.
---
 attrib/example.c    |   19 -------------------
 src/attrib-server.c |   30 ++++++++++++++++++++++++++++++
 2 files changed, 30 insertions(+), 19 deletions(-)

diff --git a/attrib/example.c b/attrib/example.c
index f28068a..41c76eb 100644
--- a/attrib/example.c
+++ b/attrib/example.c
@@ -61,7 +61,6 @@
 
 static int register_attributes(void)
 {
-	const char *devname = "Example Device";
 	const char *desc_out_temp = "Outside Temperature";
 	const char *desc_out_hum = "Outside Relative Humidity";
 	const char *desc_weight = "Rucksack Weight";
@@ -79,24 +78,6 @@ static int register_attributes(void)
 	uuid_t uuid;
 	int len;
 
-	/* GAP service: primary service definition */
-	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
-	att_put_u16(GENERIC_ACCESS_PROFILE_ID, &atval[0]);
-	attrib_db_add(0x0001, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
-
-	/* GAP service: device name characteristic */
-	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	atval[0] = ATT_CHAR_PROPER_READ;
-	att_put_u16(0x0006, &atval[1]);
-	att_put_u16(GATT_CHARAC_DEVICE_NAME, &atval[3]);
-	attrib_db_add(0x0004, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
-
-	/* GAP service: device name attribute */
-	sdp_uuid16_create(&uuid, GATT_CHARAC_DEVICE_NAME);
-	len = strlen(devname);
-	strncpy((char *) atval, devname, len);
-	attrib_db_add(0x0006, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, len);
-
 	/* GATT service: primary service definition */
 	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
 	att_put_u16(GENERIC_ATTRIB_PROFILE_ID, &atval[0]);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index cbc01ee..80f41de 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -748,6 +748,34 @@ static void confirm_event(GIOChannel *io, void *user_data)
 	return;
 }
 
+static void register_core_services(void)
+{
+	uint8_t atval[256];
+	uuid_t uuid;
+	int len;
+
+	/* GAP service: primary service definition */
+	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
+	att_put_u16(GENERIC_ACCESS_PROFILE_ID, &atval[0]);
+	attrib_db_add(0x0001, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
+
+	/* GAP service: device name characteristic */
+	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
+	atval[0] = ATT_CHAR_PROPER_READ;
+	att_put_u16(0x0006, &atval[1]);
+	att_put_u16(GATT_CHARAC_DEVICE_NAME, &atval[3]);
+	attrib_db_add(0x0004, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
+
+	/* GAP service: device name attribute */
+	sdp_uuid16_create(&uuid, GATT_CHARAC_DEVICE_NAME);
+	len = strlen(main_opts.name);
+	attrib_db_add(0x0006, &uuid, ATT_NONE, ATT_NOT_PERMITTED,
+					(uint8_t *) main_opts.name, len);
+
+	/* TODO: Implement Appearance characteristic. It is mandatory for
+	 * Peripheral/Central GAP roles. */
+}
+
 int attrib_server_init(void)
 {
 	GError *gerr = NULL;
@@ -781,6 +809,8 @@ int attrib_server_init(void)
 
 	sdp_handle = record->handle;
 
+	register_core_services();
+
 	if (!main_opts.le)
 		return 0;
 
-- 
1.7.0.4


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

* [PATCH 3/3] Move GATT service to attribute server core
  2011-01-07 20:12 [PATCH 1/3] Refactor example server to use att_put_u16() Anderson Lizardo
  2011-01-07 20:12 ` [PATCH 2/3] Move GAP service registration to src/attrib-server.c Anderson Lizardo
@ 2011-01-07 20:12 ` Anderson Lizardo
  2011-01-07 20:29 ` [PATCH 1/3] Refactor example server to use att_put_u16() Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Anderson Lizardo @ 2011-01-07 20:12 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo

GATT service (like GAP one) should be moved to the core attribute server
because there can be only one instance of it.

There was a "Attribute Opcodes Supported" characteristic inside the GATT
service in attrib/example.c which is not defined by the Core
specification and was removed before moving the code.
---
 attrib/example.c    |   18 ------------------
 src/attrib-server.c |    5 +++++
 2 files changed, 5 insertions(+), 18 deletions(-)

diff --git a/attrib/example.c b/attrib/example.c
index 41c76eb..1911912 100644
--- a/attrib/example.c
+++ b/attrib/example.c
@@ -78,24 +78,6 @@ static int register_attributes(void)
 	uuid_t uuid;
 	int len;
 
-	/* GATT service: primary service definition */
-	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
-	att_put_u16(GENERIC_ATTRIB_PROFILE_ID, &atval[0]);
-	attrib_db_add(0x0010, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
-
-	/* GATT service: attributes opcodes characteristic */
-	sdp_uuid16_create(&uuid, GATT_CHARAC_UUID);
-	atval[0] = ATT_CHAR_PROPER_READ;
-	att_put_u16(0x0012, &atval[1]);
-	att_put_u16(OPCODES_SUPPORTED_UUID, &atval[3]);
-	attrib_db_add(0x0011, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 5);
-
-	/* GATT service: attribute opcodes supported */
-	sdp_uuid16_create(&uuid, OPCODES_SUPPORTED_UUID);
-	atval[0] = 0xFF;
-	atval[1] = 0x01;
-	attrib_db_add(0x0012, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
-
 	/* Battery state service: primary service definition */
 	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
 	att_put_u16(BATTERY_STATE_SVC_UUID, &atval[0]);
diff --git a/src/attrib-server.c b/src/attrib-server.c
index 80f41de..5db1623 100644
--- a/src/attrib-server.c
+++ b/src/attrib-server.c
@@ -774,6 +774,11 @@ static void register_core_services(void)
 
 	/* TODO: Implement Appearance characteristic. It is mandatory for
 	 * Peripheral/Central GAP roles. */
+
+	/* GATT service: primary service definition */
+	sdp_uuid16_create(&uuid, GATT_PRIM_SVC_UUID);
+	att_put_u16(GENERIC_ATTRIB_PROFILE_ID, &atval[0]);
+	attrib_db_add(0x0010, &uuid, ATT_NONE, ATT_NOT_PERMITTED, atval, 2);
 }
 
 int attrib_server_init(void)
-- 
1.7.0.4


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

* Re: [PATCH 1/3] Refactor example server to use att_put_u16()
  2011-01-07 20:12 [PATCH 1/3] Refactor example server to use att_put_u16() Anderson Lizardo
  2011-01-07 20:12 ` [PATCH 2/3] Move GAP service registration to src/attrib-server.c Anderson Lizardo
  2011-01-07 20:12 ` [PATCH 3/3] Move GATT service to attribute server core Anderson Lizardo
@ 2011-01-07 20:29 ` Johan Hedberg
  2 siblings, 0 replies; 4+ messages in thread
From: Johan Hedberg @ 2011-01-07 20:29 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth

Hi Lizardo,

On Fri, Jan 07, 2011, Anderson Lizardo wrote:
> The original code was written before att_put_u16() was implemented.
> ---
>  attrib/example.c |  162 +++++++++++++++---------------------------------------
>  1 files changed, 45 insertions(+), 117 deletions(-)

All three patches have been pushed upstream. Thanks.

Johan

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

end of thread, other threads:[~2011-01-07 20:29 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-01-07 20:12 [PATCH 1/3] Refactor example server to use att_put_u16() Anderson Lizardo
2011-01-07 20:12 ` [PATCH 2/3] Move GAP service registration to src/attrib-server.c Anderson Lizardo
2011-01-07 20:12 ` [PATCH 3/3] Move GATT service to attribute server core Anderson Lizardo
2011-01-07 20:29 ` [PATCH 1/3] Refactor example server to use att_put_u16() Johan Hedberg

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).