Linux bluetooth development
 help / color / mirror / Atom feed
* [PATCH BlueZ v0 3/4] gatt: Return not found if characteritics is empty
From: Claudio Takahasi @ 2012-08-20 17:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483942-27973-1-git-send-email-claudio.takahasi@openbossa.org>

This patch changes the behaviour of Discover All Characteristics and
Discover Characteristics by UUID returning <<Attribute Not Found>> when
Characteristic list that matches the defined criteria is empty. This
scenario can happen when the GATT client avoids extra iteraction with
the remote attribute server if the last received handle(or handle + 1)
is equal to the end handle of the primary service.
---
 attrib/gatt.c |    3 ++-
 1 files changed, 2 insertions(+), 1 deletions(-)

diff --git a/attrib/gatt.c b/attrib/gatt.c
index 9ab283f..aea59ec 100644
--- a/attrib/gatt.c
+++ b/attrib/gatt.c
@@ -302,7 +302,6 @@ static void char_discovered_cb(guint8 status, const guint8 *ipdu, guint16 iplen,
 	}
 
 	att_data_list_free(list);
-	err = 0;
 
 	if (last != 0 && (last + 1 < dc->end)) {
 		buf = g_attrib_get_buffer(dc->attrib, &buflen);
@@ -321,6 +320,8 @@ static void char_discovered_cb(guint8 status, const guint8 *ipdu, guint16 iplen,
 		return;
 	}
 
+	err = (dc->characteristics ? 0 : ATT_ECODE_ATTR_NOT_FOUND);
+
 done:
 	dc->cb(dc->characteristics, err, dc->user_data);
 	discover_char_free(dc);
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 2/4] att: Replace ATT magic number
From: Claudio Takahasi @ 2012-08-20 17:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483942-27973-1-git-send-email-claudio.takahasi@openbossa.org>

This patch replaces the magic number used in Find Information Response
Format field by a proper declared constant.
---
 profiles/gatt/gas.c                |    2 +-
 profiles/input/hog_device.c        |    2 +-
 profiles/thermometer/thermometer.c |    2 +-
 3 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index 61e6745..e82513b 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -208,7 +208,7 @@ static void gatt_descriptors_cb(guint8 status, const guint8 *pdu, guint16 len,
 	if (list == NULL)
 		return;
 
-	if (format != 0x01)
+	if (format != ATT_FIND_INFO_RESP_FMT_16BIT)
 		goto done;
 
 	for (i = 0; i < list->num; i++) {
diff --git a/profiles/input/hog_device.c b/profiles/input/hog_device.c
index 5a1de12..10c5a45 100644
--- a/profiles/input/hog_device.c
+++ b/profiles/input/hog_device.c
@@ -213,7 +213,7 @@ static void discover_descriptor_cb(guint8 status, const guint8 *pdu,
 	if (list == NULL)
 		return;
 
-	if (format != 0x01)
+	if (format != ATT_FIND_INFO_RESP_FMT_16BIT)
 		goto done;
 
 	for (i = 0; i < list->num; i++) {
diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c
index ad352a9..6652a41 100644
--- a/profiles/thermometer/thermometer.c
+++ b/profiles/thermometer/thermometer.c
@@ -430,7 +430,7 @@ static void discover_desc_cb(guint8 status, const guint8 *pdu, guint16 len,
 		desc->handle = att_get_u16(value);
 		desc->ch = ch;
 
-		if (format == 0x01)
+		if (format == ATT_FIND_INFO_RESP_FMT_16BIT)
 			desc->uuid = att_get_uuid16(&value[2]);
 		else
 			desc->uuid = att_get_uuid128(&value[2]);
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 1/4] att: Add Find Info Response Format constants
From: Claudio Takahasi @ 2012-08-20 17:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483942-27973-1-git-send-email-claudio.takahasi@openbossa.org>

This patch adds constants declarations for Find Information Response
Format field. The format means that information data constains a list
of 1 or more handles with their 16-bit or 128-bit Bluetooth UUIDs
---
 attrib/att.h |    4 ++++
 1 files changed, 4 insertions(+), 0 deletions(-)

diff --git a/attrib/att.h b/attrib/att.h
index 9384be5..a563255 100644
--- a/attrib/att.h
+++ b/attrib/att.h
@@ -96,6 +96,10 @@
 #define ATT_CANCEL_ALL_PREP_WRITES              0x00
 #define ATT_WRITE_ALL_PREP_WRITES               0x01
 
+/* Find Information Response Formats */
+#define ATT_FIND_INFO_RESP_FMT_16BIT		0x01
+#define ATT_FIND_INFO_RESP_FMT_128BIT		0x02
+
 struct att_data_list {
 	uint16_t num;
 	uint16_t len;
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 0/4] GATT & ATT cleanups
From: Claudio Takahasi @ 2012-08-20 17:32 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Minor GATT & ATT cleanups. Requires: "[PATCH BlueZ v0 00/10] GATT
plugin: Service Changed and MTU exchange"

Claudio Takahasi (4):
  att: Add Find Info Response Format constants
  att: Replace ATT magic number
  gatt: Return not found if characteritics is empty
  gatt: Don't raise error if declaration was found

 attrib/att.h                       |    4 ++++
 attrib/gatt.c                      |    7 ++++---
 profiles/gatt/gas.c                |    2 +-
 profiles/input/hog_device.c        |    2 +-
 profiles/thermometer/thermometer.c |    2 +-
 5 files changed, 11 insertions(+), 6 deletions(-)

-- 
1.7.8.6


^ permalink raw reply

* [PATCH BlueZ v0 10/10] gatt: Add MTU exchange procedure
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

GATT Exchange MTU is a procedure defined by the Generic Attribute
Profile, it is not related to the remote GATT primary service. However,
gatt plugin is the most suitable place to manage this procedure.
---
 profiles/gatt/gas.c |   36 ++++++++++++++++++++++++++++++++++++
 1 files changed, 36 insertions(+), 0 deletions(-)

diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index de23a13..61e6745 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -32,6 +32,7 @@
 #include "att.h"
 #include "gattrib.h"
 #include "attio.h"
+#include "btio.h"
 #include "gatt.h"
 #include "log.h"
 #include "gas.h"
@@ -46,6 +47,7 @@ struct gas {
 	guint attioid;
 	guint changed_ind;
 	uint16_t changed_handle;
+	uint16_t mtu;
 };
 
 static GSList *devices = NULL;
@@ -250,12 +252,46 @@ static void gatt_characteristic_cb(GSList *characteristics, guint8 status,
 	gatt_find_info(gas->attrib, start, end, gatt_descriptors_cb, gas);
 }
 
+static void exchange_mtu_cb(guint8 status, const guint8 *pdu, guint16 plen,
+							gpointer user_data)
+{
+	struct gas *gas = user_data;
+	uint16_t rmtu;
+
+	if (status) {
+		error("MTU exchange: %s", att_ecode2str(status));
+		return;
+	}
+
+	if (!dec_mtu_resp(pdu, plen, &rmtu)) {
+		error("MTU exchange: protocol error");
+		return;
+	}
+
+	gas->mtu = MIN(rmtu, gas->mtu);
+	if (g_attrib_set_mtu(gas->attrib, gas->mtu))
+		DBG("MTU exchange succeeded: %d", gas->mtu);
+	else
+		DBG("MTU exchange failed");
+}
+
 static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 {
 	struct gas *gas = user_data;
+	GIOChannel *io;
+	GError *gerr = NULL;
+	uint16_t cid, imtu;
 	uint16_t app;
 
 	gas->attrib = g_attrib_ref(attrib);
+	io = g_attrib_get_channel(attrib);
+
+	if (bt_io_get(io, BT_IO_L2CAP, &gerr, BT_IO_OPT_IMTU, &imtu,
+				BT_IO_OPT_CID, &cid, BT_IO_OPT_INVALID)) {
+		gatt_exchange_mtu(gas->attrib, imtu, exchange_mtu_cb, gas);
+		gas->mtu = imtu;
+		DBG("MTU Exchange: Requesting %d", imtu);
+	}
 
 	gas->changed_ind = g_attrib_register(gas->attrib, ATT_OP_HANDLE_IND,
 						indication_cb, gas, NULL);
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 09/10] core: Rename services_changed to uuids_changed
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

This patch renames the services_changed function to uuids_changed to
avoid misinterpretation. "Service Changed" expression is used to refer
to a GATT operation used to notify clients that a given attribute range
in the GATT server is not valid anymore.
---
 src/device.c |    8 ++++----
 1 files changed, 4 insertions(+), 4 deletions(-)

diff --git a/src/device.c b/src/device.c
index c4b5554..7b44e27 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1409,7 +1409,7 @@ static void device_remove_drivers(struct btd_device *device, GSList *uuids)
 		sdp_list_free(records, (sdp_free_func_t) sdp_record_free);
 }
 
-static void services_changed(struct btd_device *device)
+static void uuids_changed(struct btd_device *device)
 {
 	DBusConnection *conn = get_dbus_connection();
 	char **uuids;
@@ -1689,7 +1689,7 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
 		device_remove_drivers(device, req->profiles_removed);
 
 	/* Propagate services changes */
-	services_changed(req->device);
+	uuids_changed(req->device);
 
 send_reply:
 	if (!req->msg)
@@ -1910,7 +1910,7 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data)
 	if (device->attios == NULL && device->attios_offline == NULL)
 		attio_cleanup(device);
 
-	services_changed(device);
+	uuids_changed(device);
 	if (req->msg)
 		create_device_reply(device, req);
 
@@ -2971,7 +2971,7 @@ void btd_device_add_uuid(struct btd_device *device, const char *uuid)
 	g_slist_free(uuid_list);
 
 	store_profiles(device);
-	services_changed(device);
+	uuids_changed(device);
 }
 
 const sdp_record_t *btd_device_get_record(struct btd_device *device,
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 08/10] gatt: Primary service interval may not change
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

This patch address the "Service Changed" scenario on which the start
and end Primary Service attribute handle interval doesn't change.
---
 attrib/gatt.h       |    1 +
 profiles/gatt/gas.c |    4 ++--
 src/device.c        |   15 +++++++++++++++
 src/device.h        |    2 ++
 4 files changed, 20 insertions(+), 2 deletions(-)

diff --git a/attrib/gatt.h b/attrib/gatt.h
index 7690fba..a15e92f 100644
--- a/attrib/gatt.h
+++ b/attrib/gatt.h
@@ -57,6 +57,7 @@ typedef void (*gatt_cb_t) (GSList *l, guint8 status, gpointer user_data);
 
 struct gatt_primary {
 	char uuid[MAX_LEN_UUID_STR + 1];
+	gboolean changed;
 	struct att_range range;
 };
 
diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index 3e3c3db..de23a13 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -154,7 +154,7 @@ static void indication_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
 	gas->changed.start = start;
 	gas->changed.end = end;
 
-	device_browse_primary(gas->device, NULL, NULL, FALSE);
+	btd_device_gatt_set_service_changed(gas->device, start, end);
 }
 
 static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
@@ -185,7 +185,7 @@ static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
 
 	DBG("GATT Service Changed start: 0x%04X end: 0x%04X", start, end);
 
-	device_browse_primary(gas->device, NULL, NULL, FALSE);
+	btd_device_gatt_set_service_changed(gas->device, start, end);
 }
 
 static void gatt_descriptors_cb(guint8 status, const guint8 *pdu, guint16 len,
diff --git a/src/device.c b/src/device.c
index 8626ad6..c4b5554 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2938,6 +2938,21 @@ GSList *btd_device_get_primaries(struct btd_device *device)
 	return device->primaries;
 }
 
+void btd_device_gatt_set_service_changed(struct btd_device *device,
+						uint16_t start, uint16_t end)
+{
+	GSList *l;
+
+	for (l = device->primaries; l; l = g_slist_next(l)) {
+		struct gatt_primary *prim = l->data;
+
+		if (start <= prim->range.end && end >= prim->range.start)
+			prim->changed = TRUE;
+	}
+
+	device_browse_primary(device, NULL, NULL, FALSE);
+}
+
 void btd_device_add_uuid(struct btd_device *device, const char *uuid)
 {
 	GSList *uuid_list;
diff --git a/src/device.h b/src/device.h
index 85d265a..a65de26 100644
--- a/src/device.h
+++ b/src/device.h
@@ -53,6 +53,8 @@ void device_probe_drivers(struct btd_device *device, GSList *profiles);
 const sdp_record_t *btd_device_get_record(struct btd_device *device,
 						const char *uuid);
 GSList *btd_device_get_primaries(struct btd_device *device);
+void btd_device_gatt_set_service_changed(struct btd_device *device,
+						uint16_t start, uint16_t end);
 void device_register_services(DBusConnection *conn, struct btd_device *device,
 						GSList *prim_list, int psm);
 GSList *device_services_from_record(struct btd_device *device,
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 07/10] core: Add updating GATT services
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

This patch adds the functions to manage Profiles added, and removed
after a Discover All Primary Services procedure.
---
 src/device.c |   64 ++++++++++++++++++++++++++++++++++++++++++++++++++-------
 1 files changed, 56 insertions(+), 8 deletions(-)

diff --git a/src/device.c b/src/device.c
index 57e7897..8626ad6 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1532,6 +1532,46 @@ static void update_bredr_services(struct browse_req *req, sdp_list_t *recs)
 	}
 }
 
+static gint primary_cmp(gconstpointer a, gconstpointer b)
+{
+	return memcmp(a, b, sizeof(struct gatt_primary));
+}
+
+static void update_gatt_services(struct browse_req *req, GSList *current,
+								GSList *found)
+{
+	GSList *l, *lmatch, *left = g_slist_copy(current);
+
+	/* Added Profiles */
+	for (l = found; l; l = g_slist_next(l)) {
+		struct gatt_primary *prim = l->data;
+
+		/* Entry found ? */
+		lmatch = g_slist_find_custom(current, prim, primary_cmp);
+		if (lmatch) {
+			left = g_slist_remove(left, lmatch->data);
+			continue;
+		}
+
+		/* New entry */
+		req->profiles_added = g_slist_append(req->profiles_added,
+							g_strdup(prim->uuid));
+
+		DBG("UUID Added: %s", prim->uuid);
+	}
+
+	/* Removed Profiles */
+	for (l = left; l; l = g_slist_next(l)) {
+		struct gatt_primary *prim = l->data;
+		req->profiles_removed = g_slist_append(req->profiles_removed,
+							g_strdup(prim->uuid));
+
+		DBG("UUID Removed: %s", prim->uuid);
+	}
+
+	g_slist_free(left);
+}
+
 static void store_profiles(struct btd_device *device)
 {
 	struct btd_adapter *adapter = device->adapter;
@@ -1830,11 +1870,17 @@ done:
 	return FALSE;
 }
 
+static void device_unregister_services(struct btd_device *device)
+{
+	attrib_client_unregister(device->services);
+	g_slist_free_full(device->services, g_free);
+	device->services = NULL;
+}
+
 static void primary_cb(GSList *services, guint8 status, gpointer user_data)
 {
 	struct browse_req *req = user_data;
 	struct btd_device *device = req->device;
-	GSList *l, *uuids = NULL;
 
 	if (status) {
 		if (req->msg) {
@@ -1848,20 +1894,22 @@ static void primary_cb(GSList *services, guint8 status, gpointer user_data)
 
 	device_set_temporary(device, FALSE);
 
-	for (l = services; l; l = l->next) {
-		struct gatt_primary *prim = l->data;
+	if (device->services)
+		device_unregister_services(device);
 
-		uuids = g_slist_append(uuids, prim->uuid);
-	}
+	update_gatt_services(req, device->primaries, services);
+	g_slist_free_full(device->primaries, g_free);
+	device->primaries = NULL;
 
 	device_register_services(req->conn, device, g_slist_copy(services), -1);
-	device_probe_drivers(device, uuids);
+	if (req->profiles_removed)
+		device_remove_drivers(device, req->profiles_removed);
+
+	device_probe_drivers(device, req->profiles_added);
 
 	if (device->attios == NULL && device->attios_offline == NULL)
 		attio_cleanup(device);
 
-	g_slist_free(uuids);
-
 	services_changed(device);
 	if (req->msg)
 		create_device_reply(device, req);
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 06/10] core: Rename update_services
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

This patch renames update_services functions to avoid clashing with GATT
based services.
---
 src/device.c |    6 +++---
 1 files changed, 3 insertions(+), 3 deletions(-)

diff --git a/src/device.c b/src/device.c
index 5fee11e..57e7897 100644
--- a/src/device.c
+++ b/src/device.c
@@ -1434,7 +1434,7 @@ static int rec_cmp(const void *a, const void *b)
 	return r1->handle - r2->handle;
 }
 
-static void update_services(struct browse_req *req, sdp_list_t *recs)
+static void update_bredr_services(struct browse_req *req, sdp_list_t *recs)
 {
 	struct btd_device *device = req->device;
 	struct btd_adapter *adapter = device_get_adapter(device);
@@ -1618,7 +1618,7 @@ static void search_cb(sdp_list_t *recs, int err, gpointer user_data)
 		goto send_reply;
 	}
 
-	update_services(req, recs);
+	update_bredr_services(req, recs);
 
 	if (device->tmp_records)
 		sdp_list_free(device->tmp_records,
@@ -1706,7 +1706,7 @@ static void browse_cb(sdp_list_t *recs, int err, gpointer user_data)
 			goto done;
 	}
 
-	update_services(req, recs);
+	update_bredr_services(req, recs);
 
 	adapter_get_address(adapter, &src);
 
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 05/10] gatt: Start Discover Services when handle changes
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

This patch starts the Discover All Primary services when a Service
Changed indication is received or the Service Changed characteristic
value is read.
---
 profiles/gatt/gas.c |   18 ++++++++++++++++++
 src/device.c        |    8 --------
 2 files changed, 18 insertions(+), 8 deletions(-)

diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index 4bf8090..3e3c3db 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -41,6 +41,7 @@ struct gas {
 	struct btd_device *device;
 	struct att_range gap;	/* GAP Primary service range */
 	struct att_range gatt;	/* GATT Primary service range */
+	struct att_range changed; /* Affected handle range */
 	GAttrib *attrib;
 	guint attioid;
 	guint changed_ind;
@@ -146,11 +147,20 @@ static void indication_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
 	opdu = g_attrib_get_buffer(gas->attrib, &plen);
 	olen = enc_confirmation(opdu, plen);
 	g_attrib_send(gas->attrib, 0, opdu[0], opdu, olen, NULL, NULL, NULL);
+
+	if (gas->changed.start == start && gas->changed.end == end)
+		return;
+
+	gas->changed.start = start;
+	gas->changed.end = end;
+
+	device_browse_primary(gas->device, NULL, NULL, FALSE);
 }
 
 static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
 					guint16 plen, gpointer user_data)
 {
+	struct gas *gas = user_data;
 	uint16_t start, end;
 
 	if (status) {
@@ -167,7 +177,15 @@ static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
 	start = att_get_u16(&pdu[1]);
 	end = att_get_u16(&pdu[3]);
 
+	if (gas->changed.start == start && gas->changed.end == end)
+		return;
+
+	gas->changed.start = start;
+	gas->changed.end = end;
+
 	DBG("GATT Service Changed start: 0x%04X end: 0x%04X", start, end);
+
+	device_browse_primary(gas->device, NULL, NULL, FALSE);
 }
 
 static void gatt_descriptors_cb(guint8 status, const guint8 *pdu, guint16 len,
diff --git a/src/device.c b/src/device.c
index f6161aa..5fee11e 100644
--- a/src/device.c
+++ b/src/device.c
@@ -2022,14 +2022,6 @@ int device_browse_primary(struct btd_device *device, DBusConnection *conn,
 	if (device->browse)
 		return -EBUSY;
 
-	/* FIXME: GATT service updates (implemented in update_services() for
-	 * SDP) are not supported yet. It will be supported once client side
-	 * "Services Changed" characteristic handling is implemented. */
-	if (device->primaries) {
-		error("Could not update GATT services");
-		return -ENOSYS;
-	}
-
 	req = g_new0(struct browse_req, 1);
 	req->device = btd_device_ref(device);
 	adapter_get_address(adapter, &src);
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 04/10] gatt: Confirm the indication received
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

This patch adds the ATT command reply for the Service Changed
indication value received.
---
 profiles/gatt/gas.c |    9 ++++++++-
 1 files changed, 8 insertions(+), 1 deletions(-)

diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index dda4886..4bf8090 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -124,7 +124,9 @@ static void write_ccc(GAttrib *attrib, uint16_t handle, gpointer user_data)
 static void indication_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
 {
 	struct gas *gas = user_data;
-	uint16_t handle, start, end;
+	uint16_t handle, start, end, olen;
+	size_t plen;
+	uint8_t *opdu;
 
 	if (len < 7) { /* 1-byte opcode + 2-byte handle + 4 range */
 		error("Malformed ATT notification");
@@ -139,6 +141,11 @@ static void indication_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
 		return;
 
 	DBG("Service Changed start: 0x%04X end: 0x%04X", start, end);
+
+	/* Confirming indication received */
+	opdu = g_attrib_get_buffer(gas->attrib, &plen);
+	olen = enc_confirmation(opdu, plen);
+	g_attrib_send(gas->attrib, 0, opdu[0], opdu, olen, NULL, NULL, NULL);
 }
 
 static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 03/10] gatt: Enable indication for Service Changed
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

This patch enables indication of the Service Changed characteristic
setting the indication bit in the Client Characteristic Configuration
descriptor.
---
 profiles/gatt/gas.c |   23 +++++++++++++++++++++++
 1 files changed, 23 insertions(+), 0 deletions(-)

diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index d36a457..dda4886 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -100,6 +100,27 @@ done:
 	att_data_list_free(list);
 }
 
+static void ccc_written_cb(guint8 status, const guint8 *pdu, guint16 plen,
+							gpointer user_data)
+{
+	if (status) {
+		error("Write Service Changed CCC failed: %s",
+						att_ecode2str(status));
+		return;
+	}
+
+	DBG("Service Changed indications enabled");
+}
+
+static void write_ccc(GAttrib *attrib, uint16_t handle, gpointer user_data)
+{
+	uint8_t value[2];
+
+	att_put_u16(GATT_CLIENT_CHARAC_CFG_IND_BIT, value);
+	gatt_write_char(attrib, handle, value, sizeof(value), ccc_written_cb,
+								user_data);
+}
+
 static void indication_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
 {
 	struct gas *gas = user_data;
@@ -145,6 +166,7 @@ static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
 static void gatt_descriptors_cb(guint8 status, const guint8 *pdu, guint16 len,
 							gpointer user_data)
 {
+	struct gas *gas = user_data;
 	struct att_data_list *list;
 	int i;
 	uint8_t format;
@@ -170,6 +192,7 @@ static void gatt_descriptors_cb(guint8 status, const guint8 *pdu, guint16 len,
 		ccc = att_get_u16(value);
 		uuid16 = att_get_u16(&value[2]);
 		DBG("CCC: 0x%04x UUID: 0x%04x", ccc, uuid16);
+		write_ccc(gas->attrib, ccc, user_data);
 	}
 
 done:
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 02/10] gatt: Add Service Changed CCC discovery
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

This patch adds the Client Characteristic discovery of the Service
Changed Changed characteristic.
---
 profiles/gatt/gas.c |  107 ++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 102 insertions(+), 5 deletions(-)

diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index 01017fe..d36a457 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -43,6 +43,8 @@ struct gas {
 	struct att_range gatt;	/* GATT Primary service range */
 	GAttrib *attrib;
 	guint attioid;
+	guint changed_ind;
+	uint16_t changed_handle;
 };
 
 static GSList *devices = NULL;
@@ -98,6 +100,26 @@ done:
 	att_data_list_free(list);
 }
 
+static void indication_cb(const uint8_t *pdu, uint16_t len, gpointer user_data)
+{
+	struct gas *gas = user_data;
+	uint16_t handle, start, end;
+
+	if (len < 7) { /* 1-byte opcode + 2-byte handle + 4 range */
+		error("Malformed ATT notification");
+		return;
+	}
+
+	handle = att_get_u16(&pdu[1]);
+	start = att_get_u16(&pdu[3]);
+	end = att_get_u16(&pdu[5]);
+
+	if (handle != gas->changed_handle)
+		return;
+
+	DBG("Service Changed start: 0x%04X end: 0x%04X", start, end);
+}
+
 static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
 					guint16 plen, gpointer user_data)
 {
@@ -120,14 +142,76 @@ static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
 	DBG("GATT Service Changed start: 0x%04X end: 0x%04X", start, end);
 }
 
+static void gatt_descriptors_cb(guint8 status, const guint8 *pdu, guint16 len,
+							gpointer user_data)
+{
+	struct att_data_list *list;
+	int i;
+	uint8_t format;
+
+	if (status) {
+		error("Discover all GATT characteristic descriptors: %s",
+							att_ecode2str(status));
+		return;
+	}
+
+	list = dec_find_info_resp(pdu, len, &format);
+	if (list == NULL)
+		return;
+
+	if (format != 0x01)
+		goto done;
+
+	for (i = 0; i < list->num; i++) {
+		uint16_t uuid16, ccc;
+		uint8_t *value;
+
+		value = list->data[i];
+		ccc = att_get_u16(value);
+		uuid16 = att_get_u16(&value[2]);
+		DBG("CCC: 0x%04x UUID: 0x%04x", ccc, uuid16);
+	}
+
+done:
+	att_data_list_free(list);
+}
+
+static void gatt_characteristic_cb(GSList *characteristics, guint8 status,
+							gpointer user_data)
+{
+	struct gas *gas = user_data;
+	struct gatt_char *chr;
+	uint16_t start, end;
+
+	if (status) {
+		error("Discover Service Changed handle: %s", att_ecode2str(status));
+		return;
+	}
+
+	chr = characteristics->data;
+
+	start = chr->value_handle + 1;
+	end = gas->gatt.end;
+
+	if (start <= end) {
+		error("Inconsistent database: Service Changed CCC missing");
+		return;
+	}
+
+	gas->changed_handle = chr->value_handle;
+	gatt_find_info(gas->attrib, start, end, gatt_descriptors_cb, gas);
+}
+
 static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 {
 	struct gas *gas = user_data;
-	bt_uuid_t changed_uuid;
 	uint16_t app;
 
 	gas->attrib = g_attrib_ref(attrib);
 
+	gas->changed_ind = g_attrib_register(gas->attrib, ATT_OP_HANDLE_IND,
+						indication_cb, gas, NULL);
+
 	if (device_get_appearance(gas->device, &app) < 0) {
 		bt_uuid_t uuid;
 
@@ -143,18 +227,31 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 	/*
 	 * Always read the characteristic value in the first connection
 	 * since attribute handles caching is not supported at the moment.
+	 * When re-connecting <<Service Changed>> handle and characteristic
+	 * value doesn't need to read again: known information from the
+	 * previous interaction.
 	 */
-	bt_uuid16_create(&changed_uuid, GATT_CHARAC_SERVICE_CHANGED);
+	if (gas->changed_handle == 0) {
+		bt_uuid_t uuid;
+
+		bt_uuid16_create(&uuid, GATT_CHARAC_SERVICE_CHANGED);
 
-	gatt_read_char_by_uuid(gas->attrib, gas->gatt.start,
-					gas->gatt.end, &changed_uuid,
-					gatt_service_changed_cb, gas);
+		gatt_read_char_by_uuid(gas->attrib, gas->gatt.start,
+						gas->gatt.end, &uuid,
+						gatt_service_changed_cb, gas);
+
+		gatt_discover_char(gas->attrib, gas->gatt.start, gas->gatt.end,
+					&uuid, gatt_characteristic_cb, gas);
+	}
 }
 
 static void attio_disconnected_cb(gpointer user_data)
 {
 	struct gas *gas = user_data;
 
+	g_attrib_unregister(gas->attrib, gas->changed_ind);
+	gas->changed_ind = 0;
+
 	g_attrib_unref(gas->attrib);
 	gas->attrib = NULL;
 }
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 01/10] gatt: Add Service Changed read
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi
In-Reply-To: <1345483375-27621-1-git-send-email-claudio.takahasi@openbossa.org>

This patch implements the Service Changed GATT charateristic value read.
Force reading the value is necessary while Service Changed value handle
is not stored. Indication can be lost since it is the first data sent
from the GATT server when the connection is established, and the client
may not be filtering the ATT indications.
---
 profiles/gatt/gas.c |   33 +++++++++++++++++++++++++++++++++
 1 files changed, 33 insertions(+), 0 deletions(-)

diff --git a/profiles/gatt/gas.c b/profiles/gatt/gas.c
index 54f5842..01017fe 100644
--- a/profiles/gatt/gas.c
+++ b/profiles/gatt/gas.c
@@ -98,9 +98,32 @@ done:
 	att_data_list_free(list);
 }
 
+static void gatt_service_changed_cb(guint8 status, const guint8 *pdu,
+					guint16 plen, gpointer user_data)
+{
+	uint16_t start, end;
+
+	if (status) {
+		error("Read GATT Service Changed failed: %s",
+						att_ecode2str(status));
+		return;
+	}
+
+	if (plen != 5) {
+		error("Service Changed: PDU length mismatch");
+		return;
+	}
+
+	start = att_get_u16(&pdu[1]);
+	end = att_get_u16(&pdu[3]);
+
+	DBG("GATT Service Changed start: 0x%04X end: 0x%04X", start, end);
+}
+
 static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 {
 	struct gas *gas = user_data;
+	bt_uuid_t changed_uuid;
 	uint16_t app;
 
 	gas->attrib = g_attrib_ref(attrib);
@@ -116,6 +139,16 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 	}
 
 	/* TODO: Read other GAP characteristics - See Core spec page 1739 */
+
+	/*
+	 * Always read the characteristic value in the first connection
+	 * since attribute handles caching is not supported at the moment.
+	 */
+	bt_uuid16_create(&changed_uuid, GATT_CHARAC_SERVICE_CHANGED);
+
+	gatt_read_char_by_uuid(gas->attrib, gas->gatt.start,
+					gas->gatt.end, &changed_uuid,
+					gatt_service_changed_cb, gas);
 }
 
 static void attio_disconnected_cb(gpointer user_data)
-- 
1.7.8.6


^ permalink raw reply related

* [PATCH BlueZ v0 00/10] GATT plugin: Service Changed and MTU exchange
From: Claudio Takahasi @ 2012-08-20 17:22 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

This patch series implements Service Changed attribute of the remote
Generic Attribute Profile Service, and the MTU exchange sub-procedure.

Service Changed characteristic is used to indicate to connected devices
that services have changed (i.e., added, removed or modified).

The MTU exchange sub-procedure is used by the client to set the ATT_MTU
to the maximum possible value that can be supported by both devices when
the client supports a value greater than the default ATT_MTU for the
Attribute Protocol. BlueZ host will always start this sub-procedure when
the ATT channel is established.

Claudio Takahasi (10):
  gatt: Add Service Changed read
  gatt: Add Service Changed CCC discovery
  gatt: Enable indication for Service Changed
  gatt: Confirm the indication received
  gatt: Start Discover Services when handle changes
  core: Rename update_services
  core: Add updating GATT services
  gatt: Primary service interval may not change
  core: Rename services_changed to uuids_changed
  gatt: Add MTU exchange procedure

 attrib/gatt.h       |    1 +
 profiles/gatt/gas.c |  214 +++++++++++++++++++++++++++++++++++++++++++++++++++
 src/device.c        |  101 +++++++++++++++++++------
 src/device.h        |    2 +
 4 files changed, 295 insertions(+), 23 deletions(-)

-- 
1.7.8.6


^ permalink raw reply

* Re: [PATCH BlueZ v3 00/15] gdbus: DBus.Properties + ObjectManager
From: Lucas De Marchi @ 2012-08-20 13:51 UTC (permalink / raw)
  To: Luiz Augusto von Dentz; +Cc: linux-bluetooth
In-Reply-To: <CABBYNZLNQUEiXgt1=TfoOE+fEigm4aNJR9haWAdNPMfPayH3CQ@mail.gmail.com>

On Mon, Aug 20, 2012 at 4:56 AM, Luiz Augusto von Dentz
<luiz.dentz@gmail.com> wrote:
> Hi Lucas,
>
> On Sat, Aug 18, 2012 at 9:50 AM, Lucas De Marchi
> <lucas.demarchi@profusion.mobi> wrote:
>> Hey,
>>
>> here is a third version of the changes planned to gdbus. In contrary to
>> previous versions, this patch set includes also the Object Manager, since the
>> PropertiesChanged signal was made on top of it.
>>
>> The first two patches are cosmetics to the other ones and somehow independent.
>>
>> The last two patches are examples on how we would use the API after the conversion.
>>
>> DBus.Properties.Set() is async now. We pass the message on so user can use it
>> to create the reply or error message.
>
> Another thing we discussed was getter to be async as well, but this
> had several implications:
>
> 1. Properties should be cacheable and by that it means the client can
> listen to PropertiesChanged after it knows about the initial value.
>
> 2. In case of GetAll and GetManagedObjects where all properties are
> fetched it would be extremely difficult to deal with getter being
> async, each property could cause a delay in the response and in the
> meantime the properties already fetched could have changed.
>
> 3. The error cases, when the getter fails, are complicated even more
> by libdbus not supporting changes to its items already in the
> iterator, so we would have to workaround this.
>
> So a property which the value is initially unknown by server should
> either be omitted or don't be exported as a property if the value
> cannot be cached consistently.

Additionally, we don't have async GetProperties in Bluez right now
("git grep METHOD | grep GetProperties"), so there's no urge need for
them. The one project that uses async GetProperties is oFono. I
propose we go with the simpler approach, letting the getter be sync
and when time comes to convert oFono we can think about how to handle
it (if we are not already using ell).



Lucas De Marchi

^ permalink raw reply

* Re: [PATCH BlueZ v3 13/15] gdbus: Implement PropertiesChanged signal
From: Lucas De Marchi @ 2012-08-20 13:38 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: linux-bluetooth
In-Reply-To: <20120818181429.GA30527@echo>

On Sat, Aug 18, 2012 at 3:14 PM, Vinicius Costa Gomes
<vinicius.gomes@openbossa.org> wrote:
> Hi Lucas,
>
> On 03:51 Sat 18 Aug, Lucas De Marchi wrote:
>> ---
>>  gdbus/gdbus.h  |   4 +++
>>  gdbus/object.c | 108 +++++++++++++++++++++++++++++++++++++++++++++++++++++++--
>>  2 files changed, 110 insertions(+), 2 deletions(-)
>
> [snip]
>
>> @@ -1397,3 +1405,99 @@ gboolean g_dbus_emit_signal_valist(DBusConnection *connection,
>>       return emit_signal_valist(connection, path, interface,
>>                                                       name, type, args);
>>  }
>> +
>> +static void process_properties_from_interface(struct generic_data *data,
>> +                                             struct interface_data *iface)
>> +{
>> +     GSList *l;
>> +     DBusMessage *signal;
>> +     DBusMessageIter iter, dict, array;
>> +
>> +     if (iface->pending_prop == NULL)
>> +             return;
>> +
>> +     signal = dbus_message_new_signal(data->path,
>> +                     DBUS_INTERFACE_PROPERTIES, "PropertiesChanged");
>> +     if (signal == NULL) {
>> +             error("Unable to allocate new " DBUS_INTERFACE_PROPERTIES
>> +                                             ".PropertiesChanged signal");
>> +             return;
>> +     }
>> +
>> +     iface->pending_prop = g_slist_reverse(iface->pending_prop);
>> +
>> +     dbus_message_iter_init_append(signal, &iter);
>> +     dbus_message_iter_append_basic(&iter, DBUS_TYPE_STRING, &iface->name);
>> +     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, &dict);
>> +
>> +     for (l = iface->pending_prop; l != NULL; l = l->next) {
>> +             GDBusPropertyTable *p = l->data;
>> +
>> +             if (p->get == NULL)
>> +                     continue;
>> +
>> +             if (p->exists != NULL && !p->exists(p, iface->user_data))
>> +                     continue;
>
> I was thinking about if the following scenario where I want a property that
> only gets notified when it changes, but I can't do Get() on it is something
> that we want to support. (Yeah, using signals makes more sense for this, but
> the question remains ;-))
>
> I was with the impression that that was one of the purposes of the exists()
> method.

Yeah... I'm not sure we're going to support these. I need  to convert
the other places to the new DBus.Properties to see if this is needed.
If it indeed is, then I'll write a separate patch to put this property
in the list of invalidated properties.


>
> Anyway, looks good to me.
>
>> +
>> +             append_property(iface, p, &dict);
>> +     }
>> +
>> +     dbus_message_iter_close_container(&iter, &dict);
>> +     dbus_message_iter_open_container(&iter, DBUS_TYPE_ARRAY,
>> +                             DBUS_TYPE_STRING_AS_STRING, &array);
>> +     dbus_message_iter_close_container(&iter, &array);

Here... this is the empty array that we are sending now. If we need
the case above I'll fill it here.

Thanks
Lucas De Marchi

>> +
>> +     g_dbus_send_message(data->conn, signal);
>> +
>> +     g_slist_free(iface->pending_prop);
>> +     iface->pending_prop = NULL;
>> +}
>> +
>> +static void process_property_changes(struct generic_data *data)
>> +{
>> +     GSList *l;
>> +
>> +     for (l = data->interfaces; l != NULL; l = l->next) {
>> +             struct interface_data *iface = l->data;
>> +
>> +             process_properties_from_interface(data, iface);
>> +     }
>> +
>> +     data->pending_prop = FALSE;
>> +}
>> +
>> +void g_dbus_emit_property_changed(DBusConnection *connection,
>> +                             const char *path, const char *interface,
>> +                             const char *name)
>> +{
>> +     const GDBusPropertyTable *property;
>> +     struct generic_data *data;
>> +     struct interface_data *iface;
>> +
>> +     if (!dbus_connection_get_object_path_data(connection, path,
>> +                                     (void **) &data) || data == NULL)
>> +             return;
>> +
>> +     iface = find_interface(data->interfaces, interface);
>> +     if (iface == NULL)
>> +             return;
>> +
>> +     property = find_property(iface->properties, name);
>> +     if (property == NULL) {
>> +             error("Could not find property %s in %p", name,
>> +                                                     iface->properties);
>> +             return;
>> +     }
>> +
>> +     data->pending_prop = TRUE;
>> +     iface->pending_prop = g_slist_prepend(iface->pending_prop,
>> +                                             (void *) property);
>> +
>> +     if (!data->process_id) {
>> +             data->process_id = g_idle_add(process_changes, data);
>> +             return;
>> +     }
>> +}
>> --
>> 1.7.11.5
>>
>> --
>> To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
>> the body of a message to majordomo@vger.kernel.org
>> More majordomo info at  http://vger.kernel.org/majordomo-info.html
>
>
> Cheers,
> --
> Vinicius

^ permalink raw reply

* Re: [PATCH v4 01/10] Battery: Add Battery Service Gatt Client
From: Luiz Augusto von Dentz @ 2012-08-20 13:03 UTC (permalink / raw)
  To: Chen Ganir, linux-bluetooth
In-Reply-To: <20120816192440.GC25826@x220.P-661HNU-F1>

Hi Chen, Johan,

On Thu, Aug 16, 2012 at 10:24 PM, Johan Hedberg <johan.hedberg@gmail.com> wrote:
> Hi Chen,
>
> On Thu, Aug 16, 2012, Chen Ganir wrote:
>> >>However, i fail to understand why the object manager prevents this
>> >>from getting accepted - do you have a time estimation when the
>> >>object manager should be active or available ?
>> >
>> >By the time of our next release (as per the content under the BlueZ 5
>> >section in our TODO file).
>>
>> Is there anywhere some documentation or instructions how to adapt
>> the API for the new object manager ? Is it backward compatible to
>> what we have today ? Do we really hold back DBUS additions until we
>> change the DBUS API ?
>
> As an unrelated thing (but since I saw it in your commit messages too):
> please spell D-Bus as D-Bus, not DBUS, DBus, or anything else in natural
> written language. This keeps it consistent with the rest of our
> documentation as well as how the D-Bus project itself spells the name.
>
> Regarding the Object Manager interface the implementation details you'd
> get from Lucas and Luiz who are working on it whereas the API spec is
> available here:
>
> http://dbus.freedesktop.org/doc/dbus-specification.html#standard-interfaces-objectmanager

With object manager we have to keep 2 things in mind while designing
new interfaces:

1. In case of returning new objects, as in CreateDevice, always
include the interfaces and properties e.g. D-Bus signature oa{sa{sv}}
(we will probably have a gdbus helper to do that) which is the
equivalent to InterfacesAdded signal. This avoid having to call
GetManagedObjects.
2. No need to keep a list of objects or emit signals when one is
created/destroyed, gdbus will take care of this automatically.

Now if this is really relevant here Im not sure.

>> >>I prefer this way of putting the batteries below the device, since it
>> >>is obvious which battery belongs to each device.
>> >
>> >I fully agree with this. It's not what I had an issue with. However, if
>> >we really want to make this clear you could additionally have a "Device"
>> >property for each battery object pointing back to the parent object.
>> I can do that, if it helps. Although it is not necessary, since the
>> object path for a battery already contains the device objec path in
>> it :
>> [variable prefix]/{hci0,..}/dev_XX_XX_XX_XX_XX_XX/BATT-NN-DDDD
>> Adding a device object path as a property will be redundant.
>
> Even though we do have such a hierarchical construction of the paths I
> don't think we should encourage this kind of magic tricks in trying look
> into actual values of object paths to infer their relation to each
> other. However, since the battery object paths would be discovered
> through the device object there might not be any need for such a
> backwards reference.
>
>> >>The other option i can think of is to have another interface
>> >>registered on the device object path:
>> >>
>> >>Service             org.bluez
>> >>Interface   org.bluez.Batteries
>> >>Object path [variable prefix]/{hci0,..}/dev_XX_XX_XX_XX_XX_XX
>> >>
>> >>Methods     dict GetProperties()
>> >>
>> >>            Returns all properties for the interface. See the
>> >>            Properties section for the available properties.
>> >>
>> >>Signals             ProperyChanged(string name, variant value)
>> >>
>> >>            This signal indicates a changed value of the given
>> >>            property.
>> >>
>> >>Properties  array{object} Batteries [readonly]
>> >>
>> >>            List of device battery object paths that represents the available
>> >>batteries on the remote devices.
>> >>
>> >>
>> >>Service             org.bluez
>> >>Interface   org.bluez.Battery
>> >>Object path [variable prefix]/{hci0,..}/dev_XX_XX_XX_XX_XX_XX/BATT-NN-DDDD
>> >>
>> >>
>> >>Methods     dict GetProperties()
>> >>
>> >>            Returns all properties for the interface. See the
>> >>            Properties section for the available properties.
>> >>
>> >>Signals             PropertyChanged(string name, variant value)
>> >>
>> >>            This signal indicates a changed value of the given
>> >>            property.
>> >>
>> >>Properties  byte Level [readonly]
>> >>
>> >>                    Battery level (0-100).
>> >>
>> >>Any other suggestion ?
>> >
>> >That would work, although both of these interfaces are rather
>> >light-weight in that they only contain a single property which begs the
>> >question whether this is a bit over-kill.
>> I know. I believe so as well, but if you want to separate the
>> interfaces, it is a must.
>>
>> >
>> >Another option is to do away with the per-battery object somehow and
>> >expose all batteries through a single interface. I'm not so sure that's
>> >a good idea though since it could prevent future extensibility of the
>> >API and doesn't reuse the common tools we have for object-like
>> >abstractions (which a battery certainly is).
>> If we do what you suggest, a battery name (namespace+descriptor)
>> will be the property name, and the value should be the battery
>> level. i'm not too comfortable with it, and it is different than
>> what we used to do up until now.
>>
>> So where do we go from here ?
>
> Some extra opinions/view points could help. Maybe Marcel or Luiz have
> some preferences/ideas on how to do this.

Im trying to think how having multiple objects could be useful for the
UI, most likely it only gonna show a single meter aggregating all the
batteries.

Another thing that worth adding is that there are other profiles that
do support battery status such as HFP and AVRCP, so I think this
should be made generic enough so other sources could be supported.

-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH] Write discoverable mode on storage after HCI response
From: Chan-yeol Park @ 2012-08-20 11:25 UTC (permalink / raw)
  To: linux-bluetooth
In-Reply-To: <1344430990-4080-1-git-send-email-chanyeol.park@samsung.com>

Hello all,

I'm writing in order to discuss the point when bluez writes Discoverable 
Mode value.

Currently BlueZ writes it on the storage right after it sends HCI command.
Except DiscoverableTimeout is 0 case. it works fine.
hciconfig, bluez Adapter.GetProperties 's value are the same with the 
discoverable mode
on the storage.

But in case of DiscoverableTimeout is not 0 the value on the storage 
should be updated
  after BlueZ gets HCI Discoverable Mode change response. However the 
change is not
  applied on the storage , so it's skipped.
* Fortunately hciconfig, Adapter.GetProperties 's value are updated fine.

I think if we move the logic that writing the value on the storage FROM 
the point before
  bluez sends HCI commands TO the point after we get HCI response , this 
problem
would be resolved naturally.

If you need more explanation, please ask me.

Regards
chanyeol

On 08/08/2012 10:03 PM, chanyeol.park@samsung.com wrote:
> From: Chan-yeol Park <chanyeol.park@samsung.com>
>
> Right after HCI mode command is sent, Bluez writes mode value
> on the storage. but in case of DiscoverableTimeout, storage value
> is not updated like adapter->mode value. So this logic is moved.
> ---
>   src/adapter.c |   11 ++++++-----
>   1 file changed, 6 insertions(+), 5 deletions(-)
>
> diff --git a/src/adapter.c b/src/adapter.c
> index acb845e..1b8e3b0 100644
> --- a/src/adapter.c
> +++ b/src/adapter.c
> @@ -302,7 +302,6 @@ static int set_mode(struct btd_adapter *adapter, uint8_t new_mode,
>   
>   done:
>   	modestr = mode2str(new_mode);
> -	write_device_mode(&adapter->bdaddr, modestr);
>   
>   	DBG("%s", modestr);
>   
> @@ -2244,6 +2243,12 @@ static void set_mode_complete(struct btd_adapter *adapter)
>   		adapter->mode_sessions = NULL;
>   	}
>   
> +	modestr = mode2str(adapter->mode);
> +
> +	DBG("%s", modestr);
> +
> +	write_device_mode(&adapter->bdaddr, modestr);
> +
>   	if (adapter->pending_mode == NULL)
>   		return;
>   
> @@ -2268,10 +2273,6 @@ static void set_mode_complete(struct btd_adapter *adapter)
>   		g_dbus_send_message(connection, reply);
>   	}
>   
> -	modestr = mode2str(adapter->mode);
> -
> -	DBG("%s", modestr);
> -
>   	/* restore if the mode doesn't matches the pending */
>   	if (err != 0) {
>   		write_device_mode(&adapter->bdaddr, modestr);


^ permalink raw reply

* Re: [PATCH BlueZ v2 00/10] GATT Plugin
From: Johan Hedberg @ 2012-08-20  9:20 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth
In-Reply-To: <1345214611-9071-1-git-send-email-claudio.takahasi@openbossa.org>

Hi Claudio,

On Fri, Aug 17, 2012, Claudio Takahasi wrote:
> This patch series adds a new GATT based plugin for GAP and GATT service.
> The objective is cleanup: moving some GATT related operations from the
> device(core) to a GATT based plugin.
> 
> This first part is related to GAP appearance characteristic. A second
> patch will be sent soon to manage Service Changed and GATT/ATT MTU.
> 
> Changes from v1: Removes direct access to appearance storage.
> 
> Claudio Takahasi (10):
>   gatt: Add Generic Access/Attribute Profile plugin
>   gatt: Add GAP/GATT device registration
>   core: Add device method to access "Appearance"
>   gatt: Add read Appearance characteristic
>   core: Remove Appearance characteristic read
>   gatt: Emit PropertyChanged for Appearance
>   core: PropertyChanged signal for Icon/class
>   core: PropertyChanged signal for Icon/Appearance
>   core: Add storing Appearance
>   gatt: Map Appearance value 0x0000 to "unknown"
> 
>  Makefile.am             |    8 ++-
>  profiles/gatt/gas.c     |  163 +++++++++++++++++++++++++++++++++++++++++++++++
>  profiles/gatt/gas.h     |   25 +++++++
>  profiles/gatt/main.c    |   52 +++++++++++++++
>  profiles/gatt/manager.c |   82 ++++++++++++++++++++++++
>  profiles/gatt/manager.h |   24 +++++++
>  src/dbus-common.c       |    2 +
>  src/device.c            |   98 ++++++++++++----------------
>  src/device.h            |    2 +
>  9 files changed, 399 insertions(+), 57 deletions(-)
>  create mode 100644 profiles/gatt/gas.c
>  create mode 100644 profiles/gatt/gas.h
>  create mode 100644 profiles/gatt/main.c
>  create mode 100644 profiles/gatt/manager.c
>  create mode 100644 profiles/gatt/manager.h

All patches in this set have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH obexd 1/2] MAP: Add offset parameter decription
From: Luiz Augusto von Dentz @ 2012-08-20  8:43 UTC (permalink / raw)
  To: Sunil Kumar Behera; +Cc: linux-bluetooth
In-Reply-To: <1345216001-8422-1-git-send-email-sunil.behera@samsung.com>

Hi Sunil,

On Fri, Aug 17, 2012 at 6:06 PM, Sunil Kumar Behera
<sunil.behera@samsung.com> wrote:
> Add offset parameter description for
> messages_get_messages_listing() function header
> ---
>  plugins/messages.h |    1 +
>  1 file changed, 1 insertion(+)
>
> diff --git a/plugins/messages.h b/plugins/messages.h
> index 83e087a..beca3a8 100644
> --- a/plugins/messages.h
> +++ b/plugins/messages.h
> @@ -215,6 +215,7 @@ int messages_get_folder_listing(void *session, const char *name, uint16_t max,
>   * session: Backend session.
>   * name: Optional subdirectory name.
>   * max: Maximum number of entries to retrieve.
> + * offset: Offset of the first entry.
>   * filter: Filter to apply on returned message listing.
>   * size: Total size of listing to be returned.
>   * newmsg: Indicates presence of unread messages.
> --
> 1.7.9.5

These 2 patches are now pushed upstream, thanks.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCHv2 hcidump 1/2] amp: Fix printing link handle
From: Johan Hedberg @ 2012-08-20  8:29 UTC (permalink / raw)
  To: Andrei Emeltchenko; +Cc: linux-bluetooth
In-Reply-To: <1345211179-3761-1-git-send-email-Andrei.Emeltchenko.news@gmail.com>

Hi Andrei,

On Fri, Aug 17, 2012, Andrei Emeltchenko wrote:
> From: Andrei Emeltchenko <andrei.emeltchenko@intel.com>
> 
> Print logical link handle as 0x%4.4x and physical link handle
> as 0x%2.2x
> ---
>  parser/hci.c |   20 +++++++++++---------
>  1 file changed, 11 insertions(+), 9 deletions(-)

Both patches have been applied. Thanks.

Johan

^ permalink raw reply

* Re: [PATCH BlueZ v3 00/15] gdbus: DBus.Properties + ObjectManager
From: Luiz Augusto von Dentz @ 2012-08-20  7:56 UTC (permalink / raw)
  To: Lucas De Marchi; +Cc: linux-bluetooth
In-Reply-To: <1345272662-2850-1-git-send-email-lucas.demarchi@profusion.mobi>

Hi Lucas,

On Sat, Aug 18, 2012 at 9:50 AM, Lucas De Marchi
<lucas.demarchi@profusion.mobi> wrote:
> Hey,
>
> here is a third version of the changes planned to gdbus. In contrary to
> previous versions, this patch set includes also the Object Manager, since the
> PropertiesChanged signal was made on top of it.
>
> The first two patches are cosmetics to the other ones and somehow independent.
>
> The last two patches are examples on how we would use the API after the conversion.
>
> DBus.Properties.Set() is async now. We pass the message on so user can use it
> to create the reply or error message.

Another thing we discussed was getter to be async as well, but this
had several implications:

1. Properties should be cacheable and by that it means the client can
listen to PropertiesChanged after it knows about the initial value.

2. In case of GetAll and GetManagedObjects where all properties are
fetched it would be extremely difficult to deal with getter being
async, each property could cause a delay in the response and in the
meantime the properties already fetched could have changed.

3. The error cases, when the getter fails, are complicated even more
by libdbus not supporting changes to its items already in the
iterator, so we would have to workaround this.

So a property which the value is initially unknown by server should
either be omitted or don't be exported as a property if the value
cannot be cached consistently.

-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: GSoC: OBEX Filesystem In Userspace
From: Luiz Augusto von Dentz @ 2012-08-20  7:17 UTC (permalink / raw)
  To: dmp; +Cc: linux-bluetooth, Vinicius Gomes
In-Reply-To: <CAKZqhqfEbuFELtqCkz2yz_YfoA8HNvxDMqT39h4X-V+CKxm7sQ@mail.gmail.com>

Hi Michal,

On Sat, Aug 18, 2012 at 7:52 PM, dmp <dmp0x7c5@gmail.com> wrote:
> Hello BlueZ Community,
>
> After Summer of Code we are reaching firm 'pencils down' date.
>
> Taking sentence from project's proposal: "Creating project using gobex
> will prove that library used by obexd has all the capabilities that
> open-obex has". I could definitely agree that gobex+glib based fuse
> filesystem - could replace obexfs. Prepared gobexfuse allows to
> listfolder, get, put, delete, mkdirs and move/copy files. From the
> user's point of view mounted gobexfuse behaves like local filesystem,
> just access time to larger files is noticeably slower due to bluetooth
> transfer.
>
> I've prepared (mentioned in previous e-mail) helpers middle layer
> between fuse and gobex operations. All functions declared by helpers.h
> could be easily used to write tool like obexftp (from openobex
> implementation). One think that I couldn't get tested (it's
> implemented) is rename operation (executed by g_obex_move).
> Unfortunately neither of my bluetooth devices supports this operation
> with their FTP profiles.

You can try against obexd, it does support move and copy action commands.


-- 
Luiz Augusto von Dentz

^ permalink raw reply

* Re: [PATCH BlueZ v3 09/15] gdbus: Group interface changes to reduce the amount of signals emitted
From: Luiz Augusto von Dentz @ 2012-08-20  7:14 UTC (permalink / raw)
  To: Vinicius Costa Gomes; +Cc: Lucas De Marchi, linux-bluetooth
In-Reply-To: <20120818182815.GC30527@echo>

Hi Vinicius,

On Sat, Aug 18, 2012 at 9:28 PM, Vinicius Costa Gomes
<vinicius.gomes@openbossa.org> wrote:
>>  static struct interface_data *find_interface(GSList *interfaces,
>> @@ -440,6 +495,7 @@ static struct interface_data *find_interface(GSList *interfaces,
>>
>>       for (list = interfaces; list; list = list->next) {
>>               struct interface_data *iface = list->data;
>> +
>
> Seems I have a special talent for spotting these things (on others patches
> ;-))
>

Also fixed now, thanks

-- 
Luiz Augusto von Dentz

^ 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