Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH v4 11/18] eir: Add support for creating proper OOB EIR
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

Address and total length field are mandatory part of OOB EIR.

---
 src/eir.c |   39 ++++++++++++++++++++++++++-------------
 src/eir.h |    2 +-
 2 files changed, 27 insertions(+), 14 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index 98a6607..d9fdb32 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -280,7 +280,7 @@ static void eir_generate_uuid128(sdp_list_t *list, uint8_t *ptr,
 	}
 }
 
-int eir_create_oob(const char *name, uint32_t cod,
+int eir_create_oob(bdaddr_t *addr, const char *name, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
@@ -288,12 +288,19 @@ int eir_create_oob(const char *name, uint32_t cod,
 {
 	sdp_list_t *l;
 	uint8_t *ptr = data;
-	uint16_t eir_len = 0;
+	uint16_t eir_optional_len = 0;
+	uint16_t eir_total_len;
 	uint16_t uuid16[HCI_MAX_EIR_LENGTH / 2];
 	int i, uuid_count = 0;
 	gboolean truncated = FALSE;
 	size_t name_len;
 
+	eir_total_len =  sizeof(uint16_t) + sizeof(bdaddr_t);
+	ptr += sizeof(uint16_t);
+
+	memcpy(ptr, addr, sizeof(bdaddr_t));
+	ptr += sizeof(bdaddr_t);
+
 	if (cod > 0) {
 		uint8_t class[3];
 
@@ -307,7 +314,7 @@ int eir_create_oob(const char *name, uint32_t cod,
 		memcpy(ptr, class, sizeof(class));
 		ptr += sizeof(class);
 
-		eir_len += sizeof(class) + 2;
+		eir_optional_len += sizeof(class) + 2;
 	}
 
 	if (hash) {
@@ -317,7 +324,7 @@ int eir_create_oob(const char *name, uint32_t cod,
 		memcpy(ptr, hash, 16);
 		ptr += 16;
 
-		eir_len += 16 + 2;
+		eir_optional_len += 16 + 2;
 	}
 
 	if (randomizer) {
@@ -327,7 +334,7 @@ int eir_create_oob(const char *name, uint32_t cod,
 		memcpy(ptr, randomizer, 16);
 		ptr += 16;
 
-		eir_len += 16 + 2;
+		eir_optional_len += 16 + 2;
 	}
 
 	name_len = strlen(name);
@@ -345,7 +352,7 @@ int eir_create_oob(const char *name, uint32_t cod,
 
 		memcpy(ptr + 2, name, name_len);
 
-		eir_len += (name_len + 2);
+		eir_optional_len += (name_len + 2);
 		ptr += (name_len + 2);
 	}
 
@@ -360,7 +367,7 @@ int eir_create_oob(const char *name, uint32_t cod,
 		*ptr++ = (did_product & 0xff00) >> 8;
 		*ptr++ = (did_version & 0x00ff);
 		*ptr++ = (did_version & 0xff00) >> 8;
-		eir_len += 10;
+		eir_optional_len += 10;
 	}
 
 	/* Group all UUID16 types */
@@ -378,7 +385,8 @@ int eir_create_oob(const char *name, uint32_t cod,
 			continue;
 
 		/* Stop if not enough space to put next UUID16 */
-		if ((eir_len + 2 + sizeof(uint16_t)) > HCI_MAX_EIR_LENGTH) {
+		if ((eir_optional_len + 2 + sizeof(uint16_t)) >
+				HCI_MAX_EIR_LENGTH) {
 			truncated = TRUE;
 			break;
 		}
@@ -392,7 +400,7 @@ int eir_create_oob(const char *name, uint32_t cod,
 			continue;
 
 		uuid16[uuid_count++] = uuid->value.uuid16;
-		eir_len += sizeof(uint16_t);
+		eir_optional_len += sizeof(uint16_t);
 	}
 
 	if (uuid_count > 0) {
@@ -402,7 +410,7 @@ int eir_create_oob(const char *name, uint32_t cod,
 		ptr[1] = truncated ? EIR_UUID16_SOME : EIR_UUID16_ALL;
 
 		ptr += 2;
-		eir_len += 2;
+		eir_optional_len += 2;
 
 		for (i = 0; i < uuid_count; i++) {
 			*ptr++ = (uuid16[i] & 0x00ff);
@@ -411,10 +419,15 @@ int eir_create_oob(const char *name, uint32_t cod,
 	}
 
 	/* Group all UUID128 types */
-	if (eir_len <= HCI_MAX_EIR_LENGTH - 2)
-		eir_generate_uuid128(uuids, ptr, &eir_len);
+	if (eir_optional_len <= HCI_MAX_EIR_LENGTH - 2)
+		eir_generate_uuid128(uuids, ptr, &eir_optional_len);
 
-	return eir_len;
+	eir_total_len += eir_optional_len;
+
+	/* store total length */
+	bt_put_le16(eir_total_len, data);
+
+	return eir_total_len;
 }
 
 gboolean eir_has_data_type(uint8_t *data, size_t len, uint8_t type)
diff --git a/src/eir.h b/src/eir.h
index 0755da5..d8c5e32 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -53,7 +53,7 @@ struct eir_data {
 void eir_data_free(struct eir_data *eir);
 int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len);
 int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len);
-int eir_create_oob(const char *name, uint32_t cod,
+int eir_create_oob(bdaddr_t *addr, const char *name, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 10/18] eir: Remove struct uuid_info
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

Remove struct uuid_info and convert functions to use sdp_record_t
list instead. This will allow to easily use services list from
struct btd_adapter to create EIR.

---
 src/eir.c |   29 ++++++++++++++++-------------
 src/eir.h |    7 +------
 2 files changed, 17 insertions(+), 19 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index b09c913..98a6607 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -222,7 +222,8 @@ int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len)
 
 #define SIZEOF_UUID128 16
 
-static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
+static void eir_generate_uuid128(sdp_list_t *list, uint8_t *ptr,
+							uint16_t *eir_len)
 {
 	int i, k, uuid_count = 0;
 	uint16_t len = *eir_len;
@@ -233,10 +234,11 @@ static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
 	uuid128 = ptr + 2;
 
 	for (; list; list = list->next) {
-		struct uuid_info *uuid = list->data;
-		uint8_t *uuid128_data = uuid->uuid.value.uuid128.data;
+		sdp_record_t *rec = list->data;
+		uuid_t *uuid = &rec->svclass;
+		uint8_t *uuid128_data = uuid->value.uuid128.data;
 
-		if (uuid->uuid.type != SDP_UUID128)
+		if (uuid->type != SDP_UUID128)
 			continue;
 
 		/* Stop if not enough space to put next UUID128 */
@@ -282,9 +284,9 @@ int eir_create_oob(const char *name, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
-			GSList *uuids, uint8_t *data)
+			sdp_list_t *uuids, uint8_t *data)
 {
-	GSList *l;
+	sdp_list_t *l;
 	uint8_t *ptr = data;
 	uint16_t eir_len = 0;
 	uint16_t uuid16[HCI_MAX_EIR_LENGTH / 2];
@@ -362,16 +364,17 @@ int eir_create_oob(const char *name, uint32_t cod,
 	}
 
 	/* Group all UUID16 types */
-	for (l = uuids; l != NULL; l = g_slist_next(l)) {
-		struct uuid_info *uuid = l->data;
+	for (l = uuids; l != NULL; l = l->next) {
+		sdp_record_t *rec = l->data;
+		uuid_t *uuid = &rec->svclass;
 
-		if (uuid->uuid.type != SDP_UUID16)
+		if (uuid->type != SDP_UUID16)
 			continue;
 
-		if (uuid->uuid.value.uuid16 < 0x1100)
+		if (uuid->value.uuid16 < 0x1100)
 			continue;
 
-		if (uuid->uuid.value.uuid16 == PNP_INFO_SVCLASS_ID)
+		if (uuid->value.uuid16 == PNP_INFO_SVCLASS_ID)
 			continue;
 
 		/* Stop if not enough space to put next UUID16 */
@@ -382,13 +385,13 @@ int eir_create_oob(const char *name, uint32_t cod,
 
 		/* Check for duplicates */
 		for (i = 0; i < uuid_count; i++)
-			if (uuid16[i] == uuid->uuid.value.uuid16)
+			if (uuid16[i] == uuid->value.uuid16)
 				break;
 
 		if (i < uuid_count)
 			continue;
 
-		uuid16[uuid_count++] = uuid->uuid.value.uuid16;
+		uuid16[uuid_count++] = uuid->value.uuid16;
 		eir_len += sizeof(uint16_t);
 	}
 
diff --git a/src/eir.h b/src/eir.h
index 036172e..0755da5 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -38,11 +38,6 @@
 #define EIR_DEVICE_ID               0x10  /* device ID */
 #define EIR_GAP_APPEARANCE          0x19  /* GAP appearance */
 
-struct uuid_info {
-	uuid_t uuid;
-	uint8_t svc_hint;
-};
-
 struct eir_data {
 	GSList *services;
 	int flags;
@@ -62,7 +57,7 @@ int eir_create_oob(const char *name, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
-			GSList *uuids, uint8_t *data);
+			sdp_list_t *uuids, uint8_t *data);
 
 gboolean eir_has_data_type(uint8_t *data, size_t len, uint8_t type);
 
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 09/18] eir: Return number of bytes written by eir_create_oob
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

In OOB EIR is not zero padded.

---
 src/eir.c |    4 +++-
 src/eir.h |    2 +-
 2 files changed, 4 insertions(+), 2 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index ac9d13f..b09c913 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -278,7 +278,7 @@ static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
 	}
 }
 
-void eir_create_oob(const char *name, uint32_t cod,
+int eir_create_oob(const char *name, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
@@ -410,6 +410,8 @@ void eir_create_oob(const char *name, uint32_t cod,
 	/* Group all UUID128 types */
 	if (eir_len <= HCI_MAX_EIR_LENGTH - 2)
 		eir_generate_uuid128(uuids, ptr, &eir_len);
+
+	return eir_len;
 }
 
 gboolean eir_has_data_type(uint8_t *data, size_t len, uint8_t type)
diff --git a/src/eir.h b/src/eir.h
index d5c4afc..036172e 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -58,7 +58,7 @@ struct eir_data {
 void eir_data_free(struct eir_data *eir);
 int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len);
 int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len);
-void eir_create_oob(const char *name, uint32_t cod,
+int eir_create_oob(const char *name, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 08/18] eir: Remove support for creating EIR with tx_power fields
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

This field is not used for OOB EIR.

---
 src/eir.c |    9 +--------
 src/eir.h |    2 +-
 2 files changed, 2 insertions(+), 9 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index f291bc5..ac9d13f 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -278,7 +278,7 @@ static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
 	}
 }
 
-void eir_create_oob(const char *name, int8_t tx_power, uint32_t cod,
+void eir_create_oob(const char *name, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
@@ -347,13 +347,6 @@ void eir_create_oob(const char *name, int8_t tx_power, uint32_t cod,
 		ptr += (name_len + 2);
 	}
 
-	if (tx_power != 0) {
-		*ptr++ = 2;
-		*ptr++ = EIR_TX_POWER;
-		*ptr++ = (uint8_t) tx_power;
-		eir_len += 3;
-	}
-
 	if (did_vendor != 0x0000) {
 		*ptr++ = 9;
 		*ptr++ = EIR_DEVICE_ID;
diff --git a/src/eir.h b/src/eir.h
index 55289f9..d5c4afc 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -58,7 +58,7 @@ struct eir_data {
 void eir_data_free(struct eir_data *eir);
 int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len);
 int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len);
-void eir_create_oob(const char *name, int8_t tx_power, uint32_t cod,
+void eir_create_oob(const char *name, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 07/18] eir: Rename eir_create to eir_create_oob
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

With mgmt interface EIR is created by kernel. Renaming this function
makes it clear what is a purpose of it in userspace. It also contains
support for EIR data types that shall be transmitted only over OOB
channel.

---
 src/eir.c |    2 +-
 src/eir.h |    2 +-
 2 files changed, 2 insertions(+), 2 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index e006a9f..f291bc5 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -278,7 +278,7 @@ static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
 	}
 }
 
-void eir_create(const char *name, int8_t tx_power, uint32_t cod,
+void eir_create_oob(const char *name, int8_t tx_power, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
diff --git a/src/eir.h b/src/eir.h
index 1c7a603..55289f9 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -58,7 +58,7 @@ struct eir_data {
 void eir_data_free(struct eir_data *eir);
 int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len);
 int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len);
-void eir_create(const char *name, int8_t tx_power, uint32_t cod,
+void eir_create_oob(const char *name, int8_t tx_power, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 06/18] eir: Add support for creating EIR with CoD field
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

This will be used to create EIR to be send over OOB channel.

---
 src/eir.c |   18 +++++++++++++++++-
 src/eir.h |    2 +-
 2 files changed, 18 insertions(+), 2 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index 91c431f..e006a9f 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -278,7 +278,7 @@ static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
 	}
 }
 
-void eir_create(const char *name, int8_t tx_power,
+void eir_create(const char *name, int8_t tx_power, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
@@ -292,6 +292,22 @@ void eir_create(const char *name, int8_t tx_power,
 	gboolean truncated = FALSE;
 	size_t name_len;
 
+	if (cod > 0) {
+		uint8_t class[3];
+
+		class[0] = (uint8_t) cod;
+		class[1] = (uint8_t) (cod >> 8);
+		class[2] = (uint8_t) (cod >> 16);
+
+		*ptr++ = 4;
+		*ptr++ = EIR_CLASS_OF_DEV;
+
+		memcpy(ptr, class, sizeof(class));
+		ptr += sizeof(class);
+
+		eir_len += sizeof(class) + 2;
+	}
+
 	if (hash) {
 		*ptr++ = 17;
 		*ptr++ = EIR_SSP_HASH;
diff --git a/src/eir.h b/src/eir.h
index 844c162..1c7a603 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -58,7 +58,7 @@ struct eir_data {
 void eir_data_free(struct eir_data *eir);
 int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len);
 int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len);
-void eir_create(const char *name, int8_t tx_power,
+void eir_create(const char *name, int8_t tx_power, uint32_t cod,
 			uint8_t *hash, uint8_t *randomizer,
 			uint16_t did_vendor, uint16_t did_product,
 			uint16_t did_version, uint16_t did_source,
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 05/18] eir: Add support creating EIR with hash and randomizer fields
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

This will be used to create EIR to be send over OOB channel.

---
 src/eir.c |   28 +++++++++++++++++++++++++---
 src/eir.h |    8 +++++---
 2 files changed, 30 insertions(+), 6 deletions(-)

diff --git a/src/eir.c b/src/eir.c
index 26071c4..91c431f 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -278,9 +278,11 @@ static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
 	}
 }
 
-void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
-			uint16_t did_product, uint16_t did_version,
-			uint16_t did_source, GSList *uuids, uint8_t *data)
+void eir_create(const char *name, int8_t tx_power,
+			uint8_t *hash, uint8_t *randomizer,
+			uint16_t did_vendor, uint16_t did_product,
+			uint16_t did_version, uint16_t did_source,
+			GSList *uuids, uint8_t *data)
 {
 	GSList *l;
 	uint8_t *ptr = data;
@@ -290,6 +292,26 @@ void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
 	gboolean truncated = FALSE;
 	size_t name_len;
 
+	if (hash) {
+		*ptr++ = 17;
+		*ptr++ = EIR_SSP_HASH;
+
+		memcpy(ptr, hash, 16);
+		ptr += 16;
+
+		eir_len += 16 + 2;
+	}
+
+	if (randomizer) {
+		*ptr++ = 17;
+		*ptr++ = EIR_SSP_RANDOMIZER;
+
+		memcpy(ptr, randomizer, 16);
+		ptr += 16;
+
+		eir_len += 16 + 2;
+	}
+
 	name_len = strlen(name);
 
 	if (name_len > 0) {
diff --git a/src/eir.h b/src/eir.h
index d2d6dc7..844c162 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -58,9 +58,11 @@ struct eir_data {
 void eir_data_free(struct eir_data *eir);
 int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len);
 int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len);
-void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
-			uint16_t did_product, uint16_t did_version,
-			uint16_t did_source, GSList *uuids, uint8_t *data);
+void eir_create(const char *name, int8_t tx_power,
+			uint8_t *hash, uint8_t *randomizer,
+			uint16_t did_vendor, uint16_t did_product,
+			uint16_t did_version, uint16_t did_source,
+			GSList *uuids, uint8_t *data);
 
 gboolean eir_has_data_type(uint8_t *data, size_t len, uint8_t type);
 
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 04/18] eir: Add eir_parse_oob function
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

This will parse EIR received over OOB. Such EIR contains mandatory
and optional part.

---
 src/eir.c |   25 +++++++++++++++++++++++++
 src/eir.h |    2 ++
 2 files changed, 27 insertions(+)

diff --git a/src/eir.c b/src/eir.c
index e380b0f..26071c4 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -38,6 +38,8 @@
 #include "glib-helper.h"
 #include "eir.h"
 
+#define EIR_OOB_MIN (2 + 6)
+
 void eir_data_free(struct eir_data *eir)
 {
 	g_slist_free_full(eir->services, g_free);
@@ -195,6 +197,29 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len)
 	return 0;
 }
 
+int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len)
+{
+
+	if (eir_len < EIR_OOB_MIN)
+		return -1;
+
+	if (eir_len != bt_get_le16(eir_data))
+		return -1;
+
+	eir_data += sizeof(uint16_t);
+	eir_len -= sizeof(uint16_t);
+
+	memcpy(&eir->addr, eir_data, sizeof(bdaddr_t));
+	eir_data += sizeof(bdaddr_t);
+	eir_len -= sizeof(bdaddr_t);
+
+	/* optional OOB EIR data */
+	if (eir_len > 0)
+		return eir_parse(eir, eir_data, eir_len);
+
+	return 0;
+}
+
 #define SIZEOF_UUID128 16
 
 static void eir_generate_uuid128(GSList *list, uint8_t *ptr, uint16_t *eir_len)
diff --git a/src/eir.h b/src/eir.h
index 3a52563..d2d6dc7 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -52,10 +52,12 @@ struct eir_data {
 	gboolean name_complete;
 	uint8_t *hash;
 	uint8_t *randomizer;
+	bdaddr_t addr;
 };
 
 void eir_data_free(struct eir_data *eir);
 int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len);
+int eir_parse_oob(struct eir_data *eir, uint8_t *eir_data, uint16_t eir_len);
 void eir_create(const char *name, int8_t tx_power, uint16_t did_vendor,
 			uint16_t did_product, uint16_t did_version,
 			uint16_t did_source, GSList *uuids, uint8_t *data);
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 03/18] eir: Store class in struct eir_data as uint32_t
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

This simplify code as class is stored on storage as uint32_t and
had to be converted to it in few places.

---
 src/adapter.c |   11 ++++-------
 src/eir.c     |    3 ++-
 src/eir.h     |    2 +-
 src/event.c   |   11 +++--------
 src/event.h   |    2 +-
 src/mgmt.c    |    2 +-
 6 files changed, 12 insertions(+), 19 deletions(-)

diff --git a/src/adapter.c b/src/adapter.c
index a6a4a4b..4ca0c53 100644
--- a/src/adapter.c
+++ b/src/adapter.c
@@ -3063,7 +3063,6 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
 	struct eir_data eir_data;
 	char *alias, *name;
 	gboolean legacy, name_known;
-	uint32_t dev_class;
 	int err;
 	GSList *l;
 
@@ -3074,10 +3073,8 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
 		return;
 	}
 
-	dev_class = eir_data.dev_class[0] | (eir_data.dev_class[1] << 8) |
-						(eir_data.dev_class[2] << 16);
-	if (dev_class != 0)
-		write_remote_class(&adapter->bdaddr, bdaddr, dev_class);
+	if (eir_data.class != 0)
+		write_remote_class(&adapter->bdaddr, bdaddr, eir_data.class);
 
 	if (eir_data.appearance != 0)
 		write_remote_appearance(&adapter->bdaddr, bdaddr, bdaddr_type,
@@ -3133,8 +3130,8 @@ void adapter_update_found_devices(struct btd_adapter *adapter,
 	alias = read_stored_data(&adapter->bdaddr, bdaddr, bdaddr_type,
 								"aliases");
 
-	dev = found_device_new(bdaddr, bdaddr_type, name, alias, dev_class,
-						legacy, eir_data.flags);
+	dev = found_device_new(bdaddr, bdaddr_type, name, alias,
+				eir_data.class, legacy, eir_data.flags);
 	free(name);
 	free(alias);
 
diff --git a/src/eir.c b/src/eir.c
index 9226c32..e380b0f 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -166,7 +166,8 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len)
 		case EIR_CLASS_OF_DEV:
 			if (data_len < 3)
 				break;
-			memcpy(eir->dev_class, data, 3);
+			eir->class = data[0] | (data[1] << 8) |
+							(data[2] << 16);
 			break;
 
 		case EIR_GAP_APPEARANCE:
diff --git a/src/eir.h b/src/eir.h
index e6e870a..3a52563 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -47,7 +47,7 @@ struct eir_data {
 	GSList *services;
 	int flags;
 	char *name;
-	uint8_t dev_class[3];
+	uint32_t class;
 	uint16_t appearance;
 	gboolean name_complete;
 	uint8_t *hash;
diff --git a/src/event.c b/src/event.c
index 1db73be..9626053 100644
--- a/src/event.c
+++ b/src/event.c
@@ -452,7 +452,7 @@ int btd_event_ltk_notify(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
 }
 
 void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
-						char *name, uint8_t *dev_class)
+						char *name, uint32_t class)
 {
 	struct btd_adapter *adapter;
 	struct btd_device *device;
@@ -462,13 +462,8 @@ void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_typ
 
 	update_lastused(local, peer, bdaddr_type);
 
-	if (dev_class != NULL) {
-		uint32_t class = dev_class[0] | (dev_class[1] << 8) |
-							(dev_class[2] << 16);
-
-		if (class != 0)
-			write_remote_class(local, peer, class);
-	}
+	if (class != 0)
+		write_remote_class(local, peer, class);
 
 	device_set_addr_type(device, bdaddr_type);
 
diff --git a/src/event.h b/src/event.h
index 7031cc9..6d001dd 100644
--- a/src/event.h
+++ b/src/event.h
@@ -30,7 +30,7 @@ void btd_event_set_legacy_pairing(bdaddr_t *local, bdaddr_t *peer, gboolean lega
 void btd_event_remote_class(bdaddr_t *local, bdaddr_t *peer, uint32_t class);
 void btd_event_remote_name(bdaddr_t *local, bdaddr_t *peer, char *name);
 void btd_event_conn_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t bdaddr_type,
-					char *name, uint8_t *dev_class);
+						char *name, uint32_t class);
 void btd_event_conn_failed(bdaddr_t *local, bdaddr_t *peer, uint8_t status);
 void btd_event_disconn_complete(bdaddr_t *local, bdaddr_t *peer);
 void btd_event_simple_pairing_complete(bdaddr_t *local, bdaddr_t *peer, uint8_t status);
diff --git a/src/mgmt.c b/src/mgmt.c
index 5bba732..462e02b 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -515,7 +515,7 @@ static void mgmt_device_connected(int sk, uint16_t index, void *buf, size_t len)
 	btd_event_conn_complete(&info->bdaddr, &ev->addr.bdaddr,
 						ev->addr.type,
 						eir_data.name,
-						eir_data.dev_class);
+						eir_data.class);
 
 	eir_data_free(&eir_data);
 }
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 02/18] eir: Add support for parsing SSP hash and randomizer
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

This will be used over OOB mechanism.

---
 src/eir.c |   16 ++++++++++++++++
 src/eir.h |    4 ++++
 2 files changed, 20 insertions(+)

diff --git a/src/eir.c b/src/eir.c
index 50912a0..9226c32 100644
--- a/src/eir.c
+++ b/src/eir.c
@@ -44,6 +44,10 @@ void eir_data_free(struct eir_data *eir)
 	eir->services = NULL;
 	g_free(eir->name);
 	eir->name = NULL;
+	g_free(eir->hash);
+	eir->hash = NULL;
+	g_free(eir->randomizer);
+	eir->randomizer = NULL;
 }
 
 static void eir_parse_uuid16(struct eir_data *eir, void *data, uint8_t len)
@@ -170,6 +174,18 @@ int eir_parse(struct eir_data *eir, uint8_t *eir_data, uint8_t eir_len)
 				break;
 			eir->appearance = bt_get_le16(data);
 			break;
+
+		case EIR_SSP_HASH:
+			if (data_len < 16)
+				break;
+			eir->hash = g_memdup(data, 16);
+			break;
+
+		case EIR_SSP_RANDOMIZER:
+			if (data_len < 16)
+				break;
+			eir->randomizer = g_memdup(data, 16);
+			break;
 		}
 
 		eir_data += field_len + 1;
diff --git a/src/eir.h b/src/eir.h
index 3c81024..e6e870a 100644
--- a/src/eir.h
+++ b/src/eir.h
@@ -33,6 +33,8 @@
 #define EIR_NAME_COMPLETE           0x09  /* complete local name */
 #define EIR_TX_POWER                0x0A  /* transmit power level */
 #define EIR_CLASS_OF_DEV            0x0D  /* Class of Device */
+#define EIR_SSP_HASH                0x0E  /* SSP Hash */
+#define EIR_SSP_RANDOMIZER          0x0F  /* SSP Randomizer */
 #define EIR_DEVICE_ID               0x10  /* device ID */
 #define EIR_GAP_APPEARANCE          0x19  /* GAP appearance */
 
@@ -48,6 +50,8 @@ struct eir_data {
 	uint8_t dev_class[3];
 	uint16_t appearance;
 	gboolean name_complete;
+	uint8_t *hash;
+	uint8_t *randomizer;
 };
 
 void eir_data_free(struct eir_data *eir);
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 01/18] Handle missing randomizer in mgmt_add_remote_oob_data
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc
In-Reply-To: <1349270311-31103-1-git-send-email-szymon.janc@tieto.com>

Randomizer is optional. Handling missing randomizer in
mgmt_add_remote_oob_data is easy and will simplify caller code.

---
 plugins/dbusoob.c |    7 -------
 src/mgmt.c        |    4 +++-
 2 files changed, 3 insertions(+), 8 deletions(-)

diff --git a/plugins/dbusoob.c b/plugins/dbusoob.c
index 543b272..d3bca9e 100644
--- a/plugins/dbusoob.c
+++ b/plugins/dbusoob.c
@@ -232,13 +232,6 @@ static gboolean store_data(struct btd_adapter *adapter, struct oob_data *data)
 	adapter_get_address(adapter, &local);
 
 	if (data->hash) {
-		uint8_t empty_randomizer[16];
-
-		if (!data->randomizer) {
-			memset(empty_randomizer, 0, sizeof(empty_randomizer));
-			data->randomizer = empty_randomizer;
-		}
-
 		if (btd_adapter_add_remote_oob_data(adapter, &bdaddr,
 					data->hash, data->randomizer) < 0)
 			return FALSE;
diff --git a/src/mgmt.c b/src/mgmt.c
index 4354dc4..5bba732 100644
--- a/src/mgmt.c
+++ b/src/mgmt.c
@@ -2459,7 +2459,9 @@ int mgmt_add_remote_oob_data(int index, bdaddr_t *bdaddr,
 
 	bacpy(&cp->addr.bdaddr, bdaddr);
 	memcpy(cp->hash, hash, 16);
-	memcpy(cp->randomizer, randomizer, 16);
+
+	if (randomizer)
+		memcpy(cp->randomizer, randomizer, 16);
 
 	if (write(mgmt_sock, &buf, sizeof(buf)) < 0)
 		return -errno;
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 00/18] neard plugin
From: Szymon Janc @ 2012-10-03 13:18 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Szymon Janc

Next round of neard plugin patches.

Changes since v3:
- enable neard support with --enable-neard
- use g_memdup instead of g_malloc+memcpy
- introduce oob_handler functionality that allows to register cb to be called
  when certain adapter actions are completed (dbusoob plugin adjusted)
- remove static pointers from neard plugin, this data is now passed to/from
  callback as user data
- other small fixes

Comments are welcome.

-- 
BR
Szymon Janc


Szymon Janc (18):
  Handle missing randomizer in mgmt_add_remote_oob_data
  eir: Add support for parsing SSP hash and randomizer
  eir: Store class in struct eir_data as uint32_t
  eir: Add eir_parse_oob function
  eir: Add support creating EIR with hash and randomizer fields
  eir: Add support for creating EIR with CoD field
  eir: Rename eir_create to eir_create_oob
  eir: Remove support for creating EIR with tx_power fields
  eir: Return number of bytes written by eir_create_oob
  eir: Remove struct uuid_info
  eir: Add support for creating proper OOB EIR
  adapter: Add btd_adapter_get_services function
  adapter: Rename btd_adapter_get_class to btd_adapter_read_class
  adapter: Add btd_adapter_get_class function
  oob: Refactor oob callback handling and move it to adapter code
  Add initial neard plugin implementation
  neard: Implement PushOOB function
  neard: Implement RequestOOB function

 Makefile.am         |    8 +-
 acinclude.m4        |    6 +
 bootstrap-configure |    1 +
 plugins/dbusoob.c   |   69 ++-----
 plugins/neard.c     |  546 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/adapter.c       |   67 ++++++-
 src/adapter.h       |   25 ++-
 src/eir.c           |  153 ++++++++++++---
 src/eir.h           |   21 +-
 src/event.c         |   11 +-
 src/event.h         |    2 +-
 src/mgmt.c          |   16 +-
 src/oob.c           |   41 ----
 src/oob.h           |   32 ---
 14 files changed, 801 insertions(+), 197 deletions(-)
 create mode 100644 plugins/neard.c
 delete mode 100644 src/oob.c
 delete mode 100644 src/oob.h

-- 
1.7.9.5


^ permalink raw reply

* [PATCH v4 BlueZ 09/27] alert: Implement category registration in RegisterAlert()
From: Anderson Lizardo @ 2012-10-03 12:49 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Eder Ruiz Maria
In-Reply-To: <1349209490-31830-10-git-send-email-anderson.lizardo@openbossa.org>

From: Eder Ruiz Maria <eder.ruiz@openbossa.org>

The given alert category is now validated and registered.
---

v4: Modify enumeration strings to use "-" as word separator.

 profiles/alert/server.c |  102 +++++++++++++++++++++++++++++++++++++++++++++--
 1 file changed, 98 insertions(+), 4 deletions(-)

diff --git a/profiles/alert/server.c b/profiles/alert/server.c
index c0434a4..feb7b77 100644
--- a/profiles/alert/server.c
+++ b/profiles/alert/server.c
@@ -77,19 +77,113 @@ enum {
 	RINGER_NORMAL,
 };
 
+struct alert_data {
+	const char *category;
+	char *srv;
+	char *path;
+};
+
+static GSList *registered_alerts = NULL;
 static uint8_t ringer_setting = RINGER_NORMAL;
 static uint8_t alert_status = 0;
 
+static const char * const anp_categories[] = {
+	"simple",
+	"email",
+	"news",
+	"call",
+	"missed-call",
+	"sms-mms",
+	"voice-mail",
+	"schedule",
+	"high-priority",
+	"instant-message",
+};
+
+static const char * const pasp_categories[] = {
+	"ringer",
+	"vibrate",
+	"display",
+};
+
+static void alert_data_destroy(gpointer user_data)
+{
+	struct alert_data *alert = user_data;
+
+	g_free(alert->srv);
+	g_free(alert->path);
+	g_free(alert);
+}
+
+static void alert_destroy(gpointer user_data)
+{
+	g_slist_free_full(registered_alerts, alert_data_destroy);
+	registered_alerts = NULL;
+}
+
+static const char *valid_category(const char *category)
+{
+	unsigned i;
+
+	for (i = 0; i < G_N_ELEMENTS(anp_categories); i++) {
+		if (g_str_equal(anp_categories[i], category))
+			return anp_categories[i];
+	}
+
+	for (i = 0; i < G_N_ELEMENTS(pasp_categories); i++) {
+		if (g_str_equal(pasp_categories[i], category))
+			return pasp_categories[i];
+	}
+
+	return NULL;
+}
+
+static gboolean registered_category(const char *category)
+{
+	GSList *l;
+	struct alert_data *alert;
+
+	for (l = registered_alerts; l; l = g_slist_next(l)) {
+		alert = l->data;
+		if (g_str_equal(alert->category, category))
+			return TRUE;
+	}
+
+	return FALSE;
+}
+
 static DBusMessage *register_alert(DBusConnection *conn, DBusMessage *msg,
 								void *data)
 {
+	const char *sender = dbus_message_get_sender(msg);
+	char *path;
 	const char *category;
+	const char *c;
+	struct alert_data *alert;
+
+	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &c,
+			DBUS_TYPE_OBJECT_PATH, &path, DBUS_TYPE_INVALID))
+		return btd_error_invalid_args(msg);
 
-	if (!dbus_message_get_args(msg, NULL, DBUS_TYPE_STRING, &category,
-							DBUS_TYPE_INVALID))
+	category = valid_category(c);
+	if (!category) {
+		DBG("Invalid category: %s", c);
 		return btd_error_invalid_args(msg);
+	}
+
+	if (registered_category(category)) {
+		DBG("Category %s already registered", category);
+		return dbus_message_new_method_return(msg);
+	}
+
+	alert = g_new0(struct alert_data, 1);
+	alert->srv = g_strdup(sender);
+	alert->path = g_strdup(path);
+	alert->category = category;
+
+	registered_alerts = g_slist_append(registered_alerts, alert);
 
-	DBG("RegisterAlert: %s", category);
+	DBG("RegisterAlert(\"%s\", \"%s\")", alert->category, alert->path);
 
 	return dbus_message_new_method_return(msg);
 }
@@ -290,7 +384,7 @@ int alert_server_init(void)
 	if (!g_dbus_register_interface(btd_get_dbus_connection(),
 					ALERT_OBJECT_PATH, ALERT_INTERFACE,
 					alert_methods, NULL, NULL, NULL,
-					NULL)) {
+					alert_destroy)) {
 		error("D-Bus failed to register %s interface",
 							ALERT_INTERFACE);
 		return -EIO;
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH v4 BlueZ 01/27] doc: Introduce Alert API
From: Anderson Lizardo @ 2012-10-03 12:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Anderson Lizardo
In-Reply-To: <1349209490-31830-2-git-send-email-anderson.lizardo@openbossa.org>

This API will be implemented and initially used by Phone Alert Status
and Alert Notification GATT profiles (server role).
---

v4: Modify enumeration strings to use "-" as word separator.

 Makefile.am       |    2 +-
 doc/alert-api.txt |  109 +++++++++++++++++++++++++++++++++++++++++++++++++++++
 2 files changed, 110 insertions(+), 1 deletion(-)
 create mode 100644 doc/alert-api.txt

diff --git a/Makefile.am b/Makefile.am
index c27eb01..470dbad 100644
--- a/Makefile.am
+++ b/Makefile.am
@@ -396,7 +396,7 @@ EXTRA_DIST += doc/manager-api.txt \
 		doc/network-api.txt doc/input-api.txt doc/audio-api.txt \
 		doc/control-api.txt doc/hfp-api.txt doc/health-api.txt \
 		doc/sap-api.txt doc/media-api.txt doc/assigned-numbers.txt \
-		doc/supported-features.txt
+		doc/supported-features.txt doc/alert-api.txt
 
 AM_YFLAGS = -d
 
diff --git a/doc/alert-api.txt b/doc/alert-api.txt
new file mode 100644
index 0000000..bcaaaf3
--- /dev/null
+++ b/doc/alert-api.txt
@@ -0,0 +1,109 @@
+BlueZ D-Bus Alert API description
+*********************************
+
+Copyright (C) 2012  Instituto Nokia de Tecnologia - INdT
+
+Introduction
+------------
+
+Currently, there are two different GATT server profiles that depend on
+receiving alerts or notifications from the platform: Phone Alert Status (PASP)
+and Alert Notification (ANP). PASP is very specific to mobile phones, and also
+allows limited control to alerts (i.e. mute once or switch to a silent mode).
+
+This document presents a unified API that allows to register and notify alerts,
+and to control some alerts (using the provided agent object).
+
+
+Alert hierarchy
+===============
+
+Service		org.bluez
+Interface	org.bluez.Alert
+Object path	/org/bluez
+
+Methods		void RegisterAlert(string category, object agent)
+
+			Register a new alert category and an agent for it. This
+			means the application will be responsible for notifying
+			BlueZ of any alerts of that category, using the
+			NewAlert() method.
+
+			Supported ANP categories: simple, email, news, call,
+				missed-call, sms-mms, voice-mail, schedule,
+				high-priority, instant-message
+			Supported PASP categories: ringer, vibrate, display
+
+			Possible Errors: org.bluez.Error.InvalidArguments
+
+		void NewAlert(string category, uint16 count, string description)
+
+			Notify BlueZ of new alert(s) for the given category. The
+			description is relative to the last received alert and
+			can be sender name, caller ID, title, or other
+			information specific to the category.
+
+			For ringer, vibrate and display categories, valid
+			descriptions are "active" and "not active". Alerts from
+			ringer category also accept "enabled" and "disabled",
+			depending on whether ringer is in silent mode or not.
+
+			Description must not exceed 18 bytes when encoded in
+			UTF-8 format, otherwise an error is returned. If there
+			is no description, an empty string should be used.
+
+			The count argument contains the number of alerts not
+			yet acknowledged by the user on the UI. To save D-Bus
+			traffic, events that may generate multiple alerts at
+			the same time (like email, sms, news) should trigger a
+			single NewAlert().
+
+			If there are more than 254 new alerts, count must be
+			set to 255. PASP alerts should always set count to 1.
+
+			Possible Errors: org.bluez.Error.InvalidArguments
+
+		void UnreadAlert(string category, uint16 count)
+
+			Some services (like SMS and e-mail) keep track of
+			number of unread items. This method allows to update
+			this counter, so peer devices can be notified using
+			Alert Notification Profile.
+
+			If there are more than 254 unread alerts, count must be
+			set to 255.
+
+			Possible Errors: org.bluez.Error.InvalidArguments
+
+Alert Agent hierarchy
+=====================
+
+Service		org.bluez
+Interface	org.bluez.AlertAgent
+Object path	freely definable
+
+Methods		void MuteOnce()
+
+			This method is only called if "ringer" alert category
+			is specified when registering the agent.
+
+			Mute the ringer once (e.g. during a incoming call). If
+			ringer is not active, does nothing.
+
+		void SetRinger(string mode)
+
+			This method is only called if "ringer" alert category
+			is specified when registering the agent.
+
+			Set ringer to the specified mode. If mode is "enabled",
+			ringer is set to the default mode, as defined by the
+			current active profile. If mode is "disabled", ringer
+			will not activate on incoming calls, until it is set
+			back to "enabled" mode.
+
+			Possible Errors: org.bluez.Error.InvalidArguments
+
+		void Release()
+
+			Release this agent. At this point, it will not be used
+			by BlueZ anymore and can be destroyed by the owner.
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH] Bluetooth: L2CAP: Fix using default Flush Timeout for EFS
From: Andrei Emeltchenko @ 2012-10-03 11:45 UTC (permalink / raw)
  To: linux-bluetooth

From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>

There are two Flush Timeouts: one is old Flush Timeot Option
which is 2 octets and the second is Flush Timeout inside EFS
which is 4 octets long.

Signed-off-by: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
---
 include/net/bluetooth/l2cap.h |    3 ++-
 net/bluetooth/l2cap_core.c    |   10 ++++++----
 2 files changed, 8 insertions(+), 5 deletions(-)

diff --git a/include/net/bluetooth/l2cap.h b/include/net/bluetooth/l2cap.h
index ab58b81..83fb9c7 100644
--- a/include/net/bluetooth/l2cap.h
+++ b/include/net/bluetooth/l2cap.h
@@ -32,7 +32,8 @@
 /* L2CAP defaults */
 #define L2CAP_DEFAULT_MTU		672
 #define L2CAP_DEFAULT_MIN_MTU		48
-#define L2CAP_DEFAULT_FLUSH_TO		0xffff
+#define L2CAP_DEFAULT_FLUSH_TO		0xFFFF
+#define L2CAP_EFS_DEFAULT_FLUSH_TO	0xFFFFFFFF
 #define L2CAP_DEFAULT_TX_WINDOW		63
 #define L2CAP_DEFAULT_EXT_WINDOW	0x3FFF
 #define L2CAP_DEFAULT_MAX_TX		3
diff --git a/net/bluetooth/l2cap_core.c b/net/bluetooth/l2cap_core.c
index b4e707b..ab6853d 100644
--- a/net/bluetooth/l2cap_core.c
+++ b/net/bluetooth/l2cap_core.c
@@ -504,7 +504,7 @@ void __l2cap_chan_add(struct l2cap_conn *conn, struct l2cap_chan *chan)
 	chan->local_msdu	= L2CAP_DEFAULT_MAX_SDU_SIZE;
 	chan->local_sdu_itime	= L2CAP_DEFAULT_SDU_ITIME;
 	chan->local_acc_lat	= L2CAP_DEFAULT_ACC_LAT;
-	chan->local_flush_to	= L2CAP_DEFAULT_FLUSH_TO;
+	chan->local_flush_to	= L2CAP_EFS_DEFAULT_FLUSH_TO;
 
 	l2cap_chan_hold(chan);
 
@@ -2714,8 +2714,10 @@ static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan)
 		efs.stype	= chan->local_stype;
 		efs.msdu	= cpu_to_le16(chan->local_msdu);
 		efs.sdu_itime	= cpu_to_le32(chan->local_sdu_itime);
-		efs.acc_lat	= __constant_cpu_to_le32(L2CAP_DEFAULT_ACC_LAT);
-		efs.flush_to	= __constant_cpu_to_le32(L2CAP_DEFAULT_FLUSH_TO);
+		efs.acc_lat	=
+			__constant_cpu_to_le32(L2CAP_DEFAULT_ACC_LAT);
+		efs.flush_to	=
+			__constant_cpu_to_le32(L2CAP_EFS_DEFAULT_FLUSH_TO);
 		break;
 
 	case L2CAP_MODE_STREAMING:
@@ -2732,7 +2734,7 @@ static void l2cap_add_opt_efs(void **ptr, struct l2cap_chan *chan)
 	}
 
 	l2cap_add_conf_opt(ptr, L2CAP_CONF_EFS, sizeof(efs),
-							(unsigned long) &efs);
+			   (unsigned long) &efs);
 }
 
 static void l2cap_ack_timeout(struct work_struct *work)
-- 
1.7.9.5


^ permalink raw reply related

* [PATCH 4/4] test: Update map-client to include Message.SetProperty and Message.GetProperties
From: Srinivasa Ragavan @ 2012-10-03 11:31 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Srinivasa Ragavan
In-Reply-To: <1349263917-11413-1-git-send-email-srinivasa.ragavan.venkateswaran@intel.com>

---
 test/map-client |   42 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 42 insertions(+)

diff --git a/test/map-client b/test/map-client
index 2075844..54e3900 100755
--- a/test/map-client
+++ b/test/map-client
@@ -41,6 +41,16 @@ def parse_options():
 			help="List messages in supplied CWD subdir")
 	parser.add_option("-g", "--get", action="store", dest="get_msg",
 			help="Get message contents")
+	parser.add_option("--get-properties", action="store", dest="get_msg_properties",
+			help="Get message properties")
+	parser.add_option("--mark-read", action="store", dest="mark_msg_read",
+			help="Marks the messages as read")
+	parser.add_option("--mark-unread", action="store", dest="mark_msg_unread",
+			help="Marks the messages as unread")	
+	parser.add_option("--mark-deleted", action="store", dest="mark_msg_deleted",
+			help="Deletes the message from the folder")
+	parser.add_option("--mark-undeleted", action="store", dest="mark_msg_undeleted",
+			help="Undeletes the message")
 
 	return parser.parse_args()
 
@@ -120,6 +130,22 @@ class MapClient:
 		msg.Get("", True, reply_handler=self.create_transfer_reply,
 						error_handler=self.error)
 
+	def get_message_properties(self, handle):
+		self.map.ListMessages("", dict())
+		path = self.path + "/message" + handle
+		obj = bus.get_object("org.bluez.obex.client", path)
+		msg = dbus.Interface(obj, "org.bluez.obex.Message")
+		ret = msg.GetProperties()
+		print pformat(unwrap(ret))
+	
+	def set_message_property(self, handle, prop, flag):
+		self.map.ListMessages("", dict())
+		path = self.path + "/message" + handle
+		obj = bus.get_object("org.bluez.obex.client", path)
+		msg = dbus.Interface(obj, "org.bluez.obex.Message")
+		msg.SetProperty (prop, flag);
+
+
 if  __name__ == '__main__':
 
 	dbus.mainloop.glib.DBusGMainLoop(set_as_default=True)
@@ -155,4 +181,20 @@ if  __name__ == '__main__':
 	if options.get_msg is not None:
 		map_client.get_message(options.get_msg)
 
+	if options.get_msg_properties is not None:
+		map_client.get_message_properties(options.get_msg_properties)
+
+	if options.mark_msg_read is not None:
+		map_client.set_message_property(options.mark_msg_read, "Read", True)
+
+	if options.mark_msg_unread is not None:
+		map_client.set_message_property(options.mark_msg_unread, "Read", False)
+
+	if options.mark_msg_deleted is not None:
+		map_client.set_message_property(options.mark_msg_deleted, "Deleted", True)
+
+	if options.mark_msg_undeleted is not None:
+		map_client.set_message_property(options.mark_msg_undeleted, "Deleted", False)
+
+
 	mainloop.run()
-- 
1.7.10.4


^ permalink raw reply related

* [PATCH 3/4] client-doc: Add documentation for Message.SetProperty and Message.GetProperties
From: Srinivasa Ragavan @ 2012-10-03 11:31 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Srinivasa Ragavan
In-Reply-To: <1349263917-11413-1-git-send-email-srinivasa.ragavan.venkateswaran@intel.com>

---
 doc/client-api.txt |   79 ++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 79 insertions(+)

diff --git a/doc/client-api.txt b/doc/client-api.txt
index 25fd3e4..6487146 100644
--- a/doc/client-api.txt
+++ b/doc/client-api.txt
@@ -534,6 +534,85 @@ Methods		object, dict Get(string targetfile, boolean attachment)
 			The properties of this transfer are also returned along
 			with the object path, to avoid a call to GetProperties.
 
+		dict GetProperties()
+
+			Returns all properties for the message. See the
+			properties section for available properties.
+
+		void SetProperty (string name, variant value)
+			
+			Sets value to the mentioned property. 
+
+			Possible properties: Read and Deleted.
+			
+			
+Properties	string Subject [readonly]
+
+			Message subject
+
+		string Timestamp [readonly]
+
+			Message timestamp
+
+		string Sender [readonly]
+
+			Message sender name
+
+		string SenderAddress [readonly]
+
+			Message sender address
+
+		string ReplyTo [readonly]
+
+			Message Reply-To address
+
+		string Recipient [readonly]
+
+			Message recipient name
+
+		string RecipientAddress [readonly]
+
+			Message recipient address
+
+		string Type [readonly]
+
+			Message type
+
+			Possible values: "EMAIL", "SMS_GSM",
+			"SMS_CDMA" and "MMS"
+
+		uint64 Size [readonly]
+
+			Message size in bytes
+
+		string Status [readonly]
+
+			Message reception status
+
+			Possible values: "complete",
+			"fractioned" and "notification"
+
+		boolean Priority [readonly]
+
+			Message priority flag
+
+		boolean Read [read/write]
+
+			Message read flag
+
+		boolean Deleted [writeonly]
+
+			Message read flag
+
+		boolean Sent [readonly]
+
+			Message sent flag
+
+		boolean Protected [readonly]
+
+			Message protected flag
+
+
 Transfer hierarchy
 ==================
 
-- 
1.7.10.4


^ permalink raw reply related

* [PATCH 2/4] client: Add Message.SetProperty and Message.GetProperties implementation.
From: Srinivasa Ragavan @ 2012-10-03 11:31 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Srinivasa Ragavan
In-Reply-To: <1349263917-11413-1-git-send-email-srinivasa.ragavan.venkateswaran@intel.com>

---
 client/map.c |  170 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 170 insertions(+)

diff --git a/client/map.c b/client/map.c
index e78cd68..8d6f930 100644
--- a/client/map.c
+++ b/client/map.c
@@ -28,6 +28,7 @@
 #include <string.h>
 #include <stdio.h>
 #include <glib.h>
+#include <glib/gstdio.h>
 #include <gdbus.h>
 
 #include <gobex-apparam.h>
@@ -78,6 +79,10 @@ static const char * const filter_list[] = {
 #define FILTER_BIT_MAX	15
 #define FILTER_ALL	0xFF
 
+#define STATUS_READ 0
+#define STATUS_DELETE 1
+#define FILLER_BYTE 0x30
+
 struct map_data {
 	struct obc_session *session;
 	DBusMessage *msg;
@@ -104,6 +109,7 @@ struct map_msg {
 	uint64_t size;
 	char *status;
 	uint8_t flags;
+	DBusMessage *msg;	
 };
 
 struct map_parser {
@@ -412,6 +418,163 @@ fail:
 	return reply;
 }
 
+static void set_message_status_cb(struct obc_session *session,
+						struct obc_transfer *transfer,
+						GError *err, void *user_data)
+{
+	struct map_msg *msg = user_data;
+	DBusMessage *reply;
+
+	if (err != NULL) {
+		reply = g_dbus_create_error(msg->msg,
+						ERROR_INTERFACE ".Failed",
+						"%s", err->message);
+		goto done;
+	}
+
+	reply = dbus_message_new_method_return(msg->msg);
+	if (reply == NULL) {
+		reply = g_dbus_create_error(msg->msg,
+						ERROR_INTERFACE ".Failed",
+						"%s", err->message);
+	}
+
+done:
+	g_dbus_send_message(conn, reply);
+	dbus_message_unref(msg->msg);
+	msg->msg = NULL;
+}
+
+static DBusMessage *map_msg_set_property (DBusConnection *connection,
+						DBusMessage *message, void *user_data)
+{
+	struct map_msg *msg = user_data;
+	struct obc_transfer *transfer;
+	char *property;
+	gboolean status;
+	GError *err = NULL;
+	DBusMessage *reply;
+	GObexApparam *apparam;
+	char contents[2];
+	int op;
+	DBusMessageIter args, variant;
+
+	dbus_message_iter_init(message, &args);
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_STRING) 
+		return g_dbus_create_error(message,
+				ERROR_INTERFACE ".InvalidArguments", NULL);
+
+	dbus_message_iter_get_basic(&args, &property);
+	dbus_message_iter_next (&args);
+	if (dbus_message_iter_get_arg_type(&args) != DBUS_TYPE_VARIANT) 
+		return g_dbus_create_error(message,
+				ERROR_INTERFACE ".InvalidArguments", NULL);
+	
+	dbus_message_iter_recurse(&args, &variant);
+	if (dbus_message_iter_get_arg_type(&variant) != DBUS_TYPE_BOOLEAN) 
+		return g_dbus_create_error(message,
+				ERROR_INTERFACE ".InvalidArguments", NULL);
+	
+	dbus_message_iter_get_basic(&variant, &status);
+
+	/* MAP supports modifying only these two properties. */
+	if (property && strcasecmp (property, "Read") == 0) {
+		op = STATUS_READ;
+		if (status)
+			msg->flags |= MAP_MSG_FLAG_READ;
+		else
+			msg->flags &= ~MAP_MSG_FLAG_READ;
+	} else if (property && strcasecmp (property, "Deleted") == 0)
+		op = STATUS_DELETE;
+	else {
+		return g_dbus_create_error(message,
+				ERROR_INTERFACE ".InvalidArguments", NULL);
+	}
+
+	contents[0] = FILLER_BYTE;
+	contents[1] = '\0';
+	
+	transfer = obc_transfer_put("x-bt/messageStatus", msg->handle, NULL,
+							contents, sizeof(contents), &err);
+	if (transfer == NULL)
+		goto fail;
+
+	apparam = g_obex_apparam_set_uint8(NULL, MAP_AP_STATUSINDICATOR,
+								op);
+	apparam = g_obex_apparam_set_uint8(apparam, MAP_AP_STATUSVALUE,
+								status);
+	obc_transfer_set_apparam(transfer, apparam);
+
+	if (!obc_session_queue(msg->data->session, transfer, set_message_status_cb, msg, &err))
+		goto fail;
+
+	msg->msg = dbus_message_ref (message);
+	return NULL;
+
+fail:
+	reply = g_dbus_create_error(message, ERROR_INTERFACE ".Failed", "%s",
+								err->message);
+	g_error_free(err);
+	return reply;
+}
+
+static DBusMessage *map_msg_get_properties (DBusConnection *connection,
+						DBusMessage *message, void *user_data)
+{
+	struct map_msg *msg = user_data;
+	GError *err = NULL;
+	DBusMessage *reply;
+	DBusMessageIter iter, data_array;
+	gboolean flag;
+	
+	reply = dbus_message_new_method_return(message);
+	if (reply == NULL) {
+		reply = g_dbus_create_error(message,
+						ERROR_INTERFACE ".Failed",
+						NULL);
+		goto done;
+	}
+
+	dbus_message_iter_init_append(reply, &iter);
+	dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
+					DBUS_DICT_ENTRY_BEGIN_CHAR_AS_STRING
+					DBUS_TYPE_STRING_AS_STRING
+					DBUS_TYPE_VARIANT_AS_STRING
+					DBUS_DICT_ENTRY_END_CHAR_AS_STRING,
+					&data_array);
+
+
+	obex_dbus_dict_append(&data_array, "Subject", DBUS_TYPE_STRING, &msg->subject);
+	obex_dbus_dict_append(&data_array, "Timestamp", DBUS_TYPE_STRING, &msg->timestamp);
+	obex_dbus_dict_append(&data_array, "Sender", DBUS_TYPE_STRING, &msg->sender);
+	obex_dbus_dict_append(&data_array, "SenderAddress", DBUS_TYPE_STRING,
+						&msg->sender_address);
+	obex_dbus_dict_append(&data_array, "ReplyTo", DBUS_TYPE_STRING, &msg->replyto);
+	obex_dbus_dict_append(&data_array, "Recipient", DBUS_TYPE_STRING, &msg->recipient);
+	obex_dbus_dict_append(&data_array, "RecipientAddress", DBUS_TYPE_STRING,
+								&msg->recipient_address);
+	obex_dbus_dict_append(&data_array, "Type", DBUS_TYPE_STRING, &msg->type);
+	obex_dbus_dict_append(&data_array, "Status", DBUS_TYPE_STRING, &msg->status);
+	obex_dbus_dict_append(&data_array, "Size", DBUS_TYPE_UINT64, &msg->size);
+	flag = (msg->flags & MAP_MSG_FLAG_PRIORITY) != 0;
+	obex_dbus_dict_append(&data_array, "Priority", DBUS_TYPE_BOOLEAN, &flag);
+	flag = (msg->flags & MAP_MSG_FLAG_READ) != 0;
+	obex_dbus_dict_append(&data_array, "Read", DBUS_TYPE_BOOLEAN, &flag);
+	flag = (msg->flags & MAP_MSG_FLAG_SENT) != 0;
+	obex_dbus_dict_append(&data_array, "Sent", DBUS_TYPE_BOOLEAN, &flag);
+	flag = (msg->flags & MAP_MSG_FLAG_PROTECTED) != 0;
+	obex_dbus_dict_append(&data_array, "Protected", DBUS_TYPE_BOOLEAN, &flag);
+
+	dbus_message_iter_close_container(&iter, &data_array);
+
+
+done:
+	if (err)
+		g_error_free(err);
+
+	return reply;	
+}
+
 static const GDBusMethodTable map_msg_methods[] = {
 	{ GDBUS_METHOD("Get",
 			GDBUS_ARGS({ "targetfile", "s" },
@@ -419,6 +582,13 @@ static const GDBusMethodTable map_msg_methods[] = {
 			GDBUS_ARGS({ "transfer", "o" },
 						{ "properties", "a{sv}" }),
 			map_msg_get) },
+	{ GDBUS_METHOD("GetProperties",
+			NULL,
+			GDBUS_ARGS({ "properties", "a{sv}" }),
+			map_msg_get_properties) },
+	{ GDBUS_ASYNC_METHOD("SetProperty",
+			GDBUS_ARGS({ "property", "sv" }), NULL,
+			map_msg_set_property) },
 	{ }
 };
 
-- 
1.7.10.4


^ permalink raw reply related

* [PATCH 1/4] client: Update the file offset to the beginning after writing to the file
From: Srinivasa Ragavan @ 2012-10-03 11:31 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Srinivasa Ragavan

When the transfer file is opened in O_RDWR mode, just after the contents are
written to the file, the file offset has to be set to the beginning of the
file. If not subsequent read fails. This patch fixes this.
---
 client/transfer.c |    1 +
 1 file changed, 1 insertion(+)

diff --git a/client/transfer.c b/client/transfer.c
index fbcafc8..cac3884 100644
--- a/client/transfer.c
+++ b/client/transfer.c
@@ -426,6 +426,7 @@ struct obc_transfer *obc_transfer_put(const char *type, const char *name,
 					"Writing all contents to file failed");
 			goto fail;
 		}
+		lseek(transfer->fd, 0, SEEK_SET);
 	} else {
 		if (!transfer_open(transfer, O_RDONLY, 0, err))
 			goto fail;
-- 
1.7.10.4


^ permalink raw reply related

* Re: [PATCH v3 BlueZ 01/27] doc: Introduce Alert API
From: Anderson Lizardo @ 2012-10-03 10:56 UTC (permalink / raw)
  To: Anderson Lizardo, linux-bluetooth
In-Reply-To: <20121003082118.GA12607@x220>

Hi Johan,

On Wed, Oct 3, 2012 at 4:21 AM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Lizardo,
>
> On Tue, Oct 02, 2012, Anderson Lizardo wrote:
>> +             void SetRinger(string mode)
>> +
>> +                     This method is only called if "ringer" alert category
>> +                     is specified when registering the agent.
>> +
>> +                     Set ringer to the specified mode. If mode is "enabled",
>> +                     ringer is set to the default mode, as defined by the
>> +                     current active profile. If mode is "disabled", ringer
>> +                     will not activate on incoming calls, until it is set
>> +                     back to "enabled" mode.
>> +
>> +                     Possible Errors: org.bluez.Error.InvalidArguments
>
> Since you've used a string here instead of a boolean is it correct to
> assume that you want to maintain the capability of extending the
> possible values to more than just "enabled" and "disabled"?

Yes, the idea here was to be able to extend this in case any future
GATT profile intends to control the ringer (or phone profile) to other
values.

> Does the
> current profile/service specification already proved more possibilities
> than these two values?

The Phone Alert Status (PASP) spec defines only "normal" and "silent"
modes (the other modes are Reserved). We mapped them to
"enabled/disabled" so it is more consistent with the Alert
Notification Profile (which is sharing the same D-Bus API). As PASP
only controls the ringer, it seemed logical to simply map it into the
broader ANP (which has the concept of "alert categories"). So we
created this "ringer" category and use it for PASP functionality
(along "display" and "vibrate").

See the description for RegisterAlert() and NewAlert() for more
details on how these categories work. Besides the ringer, the PASP
profile notifies state changes for the vibration motor and display
(which are mapped to "active"/"not active" alerts on the NewAlert()
API).

Regards,
-- 
Anderson Lizardo
Instituto Nokia de Tecnologia - INdT
Manaus - Brazil

^ permalink raw reply

* Re: [PATCH v3 BlueZ 01/27] doc: Introduce Alert API
From: Johan Hedberg @ 2012-10-03  8:21 UTC (permalink / raw)
  To: Anderson Lizardo; +Cc: linux-bluetooth
In-Reply-To: <1349209490-31830-2-git-send-email-anderson.lizardo@openbossa.org>

Hi Lizardo,

On Tue, Oct 02, 2012, Anderson Lizardo wrote:
> +		void SetRinger(string mode)
> +
> +			This method is only called if "ringer" alert category
> +			is specified when registering the agent.
> +
> +			Set ringer to the specified mode. If mode is "enabled",
> +			ringer is set to the default mode, as defined by the
> +			current active profile. If mode is "disabled", ringer
> +			will not activate on incoming calls, until it is set
> +			back to "enabled" mode.
> +
> +			Possible Errors: org.bluez.Error.InvalidArguments

Since you've used a string here instead of a boolean is it correct to
assume that you want to maintain the capability of extending the
possible values to more than just "enabled" and "disabled"? Does the
current profile/service specification already proved more possibilities
than these two values?

Johan

^ permalink raw reply

* Re: [PATCH BlueZ v9 1/8] core: Mutually exclude concurrent connections
From: Johan Hedberg @ 2012-10-03  8:12 UTC (permalink / raw)
  To: João Paulo Rechi Vita; +Cc: linux-bluetooth
In-Reply-To: <1349198578-2818-1-git-send-email-jprvita@openbossa.org>

Hi,

On Tue, Oct 02, 2012, João Paulo Rechi Vita wrote:
> Since controllers don't support more than one ongoing connection
> procedure at the same time, new connection attempts needs to yield if
> there is an ongoing connection procedure already.
> ---
>  src/adapter.c | 66 +++++++++++++++++++++++++++++++++++++++++++++++++++--------
>  src/device.c  |  6 +++---
>  src/device.h  |  2 +-
>  3 files changed, 62 insertions(+), 12 deletions(-)

After a couple of minor coding style cleanups this patch-set has now
been applied. Thanks.

Johan

^ permalink raw reply

* Re: Wireshark
From: Johan Hedberg @ 2012-10-03  8:04 UTC (permalink / raw)
  To: Michal.Labedzki; +Cc: linux-bluetooth, andrei.emeltchenko.news
In-Reply-To: <E50901D4F2CF69428D43141B7C8586792CFACCF507@EXMB03.eu.tieto.com>

Hi Michal,

On Wed, Oct 03, 2012, Michal.Labedzki@tieto.com wrote:
> > but it can't do any kind of high-level decoding (e.g. profiles).
> > It'd be interesting to know if it could be easily supported in
> > wireshark since right now there doesn't seem to be a viable way of
> > porting decoders from hcidump to btmon due to their very different
> > ways of handling buffers etc.
> 
> Johan, I guess Wireshark support decoding what do you need (expect
> ongoing tasks). If you have another idea how do decoding, please share
> it. Power of Wireshark is:

I think you must have misunderstood what I was trying to say. Did you
actually look into what the monitor socket we talked about is? I wasn't
trying to say wireshark shouldn't be used (so no point in iterating it's
benefits - you've already convinced me) but that its Bluetooth decoding
support be ported from traditional HCI sockets to use monitor sockets
instead. This wouldn't give us any new decoders to wireshark but it
would allow early HCI traffic decoding (e.g. on plugged in USB dongles)
which isn't possible with current wireshark or hcidump and context
discovery when tracing is started after there already exists
connections.

Considering these benefits monitor sockets compared to HCI ones is it
something you might be interested in implementing?

Johan

^ permalink raw reply

* Re: [PATCH v2 07/15] thermometer: Reformat MeasurementReceived description
From: Santiago Carot @ 2012-10-03  7:41 UTC (permalink / raw)
  To: Andrzej Kaczmarek; +Cc: linux-bluetooth@vger.kernel.org
In-Reply-To: <506AAB46.3020007@tieto.com>

Hi Andrzej,

2012/10/2 Andrzej Kaczmarek <andrzej.kaczmarek@tieto.com>:
> Hi Santiago,
>
>
> On 10/01/2012 02:08 PM, Santiago Carot wrote:
>>>>
>>>> Mantissa values must not always be 2^23-1 on special cases.
>>>> Information provided here is required for upper profiles which are
>>>> implementing an 11073-20601 protocol layer because they have to
>>>> differentiate among these values. In my opinion, documentation about
>>>> passible values for the mantissa should remain as they are.
>>>
>>>
>>>
>>> HTS specification states (see quote below) that measurement value field
>>> may
>>> be NaN in case sensor is not able to provide valid measurement. So I
>>> assume
>>> here that either it has valid data or NaN otherwise and thus there's no
>>> need
>>> to specify other special values as they should not be received here.
>>>
>>> <quote>
>>> The Temperature Measurement Value field may contain special float value
>>> NaN
>>> (0x007FFFFF) defined in IEEE 11073-20601 [4] to report an invalid result
>>> from a computation step or missing data due to the hardware’s inability
>>> to
>>> provide a valid measurement.
>>> </quote>
>>>
>>
>> IMHO that doesn't justify you to force all mantisse values to be
>> 2^23-1, first of all because the value type for this characteristic is
>> a FLOAT type, so any value that a thermometer could send, it does it
>> using the format defined for FLOAT types which is explained in
>> IEEE-11073-20601,
>> [http://developer.bluetooth.org/gatt/Pages/FormatTypes.aspx]
>>
>> On the other hand, I understand from this quote that thermometers MAY
>> set NaN in case sensor is not able to provide valid measuremen due to
>> an invalid result or missing data, but it doesn't say anything about
>> other values that a FLOAT types can take, so you are forcing to be NaN
>> other special cases that are defined for this kind of type.
>>
>> If you had a look to that spec you could see wich other special values
>> a FLOAT type could take, if not, you could at least have a look to one
>> of the whitepapers defined in bluetooth sig for transcoders.
>
>
> Just to be clear here: I do not force mantissa values to any particular
> value. Whatever is received from remote device is still dispatched to
> application as-is. I just modified description so it mentions what HTS
> specification says about this value and that's all and since it was just
> done "by the way" when reformatting description I won't push for it.
>
> But perhaps it's worth just adding note that exponent and mantissa are as in
> IEEE-11073-20601. This clearly states that apps working in IEEE-11073-20601
> ecosystem can pack both values directly into float and there's no need to
> specify all special values.
>

I strongly agree with you, that's the reason we agreed in the past to
add the note for special FLOAT values in the API in order not to
redirect developers to the IEEE standard which, in addition, isn't
free.

Regards.

^ permalink raw reply

* RE: Wireshark
From: Michal.Labedzki @ 2012-10-03  7:17 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: johan.hedberg, andrei.emeltchenko.news
In-Reply-To: <20120928135747.GD8184@aemeltch-MOBL1>

Hello,

> HCI also does not have full support for AMP HCI commands. I can send that
> log.

All logs are welcome. Andrei, please send it.

> but it can't do any kind of
> high-level decoding (e.g. profiles). It'd be interesting to know if it
> could be easily supported in wireshark since right now there doesn't
> seem to be a viable way of porting decoders from hcidump to btmon due to
> their very different ways of handling buffers etc.

Johan, I guess Wireshark support decoding what do you need (expect ongoing tasks). If you have another idea how do decoding, please share it. Power of Wireshark is:
1. Decoding all fields in protocols (+ user friendly describes and visualization bit/byte position in the frame)
2. Colors per protocol/profile to improve readability;
3. Possibility to display specified field as column (like Protocol, Length, Info; for example I display btl2cap.cid, btrfcomm.channel) [by the way, I have configured Wireshark to display column "Time" as "Absolute date and time" and additional "Delta" as "Delta time" - nice combination to working on timings]
4. Filtering logs, in Filter field you can but "btavrcp" and you see only AVRCP; or something like "btbnep.bnep_type == 0x01 || bthci_evt" - so you can display only HCI Events and BNEP packet where BNEP Type is equal 0x01.
5. (Menu) Statistics -> IO Graph, then "Y Axis -> Unit -> Bytes per Tick" and using filters - you can analyse throughput (for example: OPP, A2DP)
6. pcap file format can contain "Comments" - so everyone can share some useful additional information (per frame)


Example logs:
https://bugs.wireshark.org/bugzilla/attachment.cgi?id=9186
https://bugs.wireshark.org/bugzilla/attachment.cgi?id=9187
https://bugs.wireshark.org/bugzilla/attachment.cgi?id=9139
https://bugs.wireshark.org/bugzilla/attachment.cgi?id=9111
https://bugs.wireshark.org/bugzilla/attachment.cgi?id=9112
https://bugs.wireshark.org/bugzilla/attachment.cgi?id=9023
https://bugs.wireshark.org/bugzilla/attachment.cgi?id=9024
https://bugs.wireshark.org/bugzilla/attachment.cgi?id=9025
https://bugs.wireshark.org/bugzilla/attachment.cgi?id=7686

You can obtain Wireshark from SVN or GIT:
    svn co http://anonsvn.wireshark.org/wireshark/trunk/ wireshark
    git clone http://code.wireshark.org/git/wireshark    (I use only this one, but please note sometimes this way may not working...)

Installation:
not required: ./autogen.sh && ./configure && make -j 16 && ./wireshark

Regards / Pozdrawiam
-------------------------------------------------------------------------------------------------------------
Michał Łabędzki
ASCII: Michal Labedzki
e-mail: michal.labedzki@tieto.com
location: Poland, Wrocław, Legnicka 55F
---
Tieto Corporation / Tieto Poland
http://www.tieto.com / http://www.tieto.pl
---
Tieto Poland spółka z ograniczoną odpowiedzialnością z siedzibą w Szczecinie, ul. Malczewskiego 26. Zarejestrowana w Sądzie Rejonowym Szczecin-Centrum w Szczecinie, XIII Wydział Gospodarczy Krajowego Rejestru Sądowego pod numerem 0000124858. NIP: 8542085557. REGON: 812023656. Kapitał zakładowy: 4 271500 PLN


^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox