linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* [PATCH BlueZ 00/11] Immediate Alert patches
@ 2011-08-08 18:46 Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 01/11] Add read remote Tx Power Claudio Takahasi
                   ` (11 more replies)
  0 siblings, 12 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Dependency: none. RSSI threshold monitor patches are not required for
this patch series.

Implementation of D-Bus properties and GATT/ATT operations related to
alert level of the Immediate alert service.

Bruna Moreira (1):
  Add read remote Tx Power

Claudio Takahasi (10):
  Add Immediate Alert handle discovery
  Write Immediate Alert if necessary
  Emit PropertyChanged after writting alert
  Write Immediate Alert after discovering handle
  Request connection when writting Immediate alert
  Reset Immediate Alert after 5 seconds
  Reset the Immediate Alert at disconnection
  Set default value for ImmediateAlertLevel
  Write Immediate Alert if connected
  Fix wrong alert value for ImmediateAlertLevel

 proximity/monitor.c |  205 +++++++++++++++++++++++++++++++++++++++++++++++++--
 1 files changed, 199 insertions(+), 6 deletions(-)

-- 
1.7.6


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

* [PATCH BlueZ 01/11] Add read remote Tx Power
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 02/11] Add Immediate Alert handle discovery Claudio Takahasi
                   ` (10 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Bruna Moreira

From: Bruna Moreira <bruna.moreira@openbossa.org>

Read the remote Tx Power when the connection is established.
---
 proximity/monitor.c |   61 +++++++++++++++++++++++++++++++++++++++++++++++++++
 1 files changed, 61 insertions(+), 0 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index 216eae4..e9cf2e7 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -52,6 +52,7 @@
 #define PROXIMITY_INTERFACE "org.bluez.Proximity"
 
 #define ALERT_LEVEL_CHR_UUID 0x2A06
+#define POWER_LEVEL_CHR_UUID 0x2A07
 
 enum {
 	ALERT_NONE = 0,
@@ -71,6 +72,7 @@ struct monitor {
 	char *signallevel;		/* Path Loss RSSI level */
 	uint16_t linklosshandle;	/* Link Loss Characteristic
 					 * Value Handle */
+	uint16_t txpowerhandle;		/* Tx Characteristic Value Handle */
 	guint attioid;
 };
 
@@ -175,6 +177,62 @@ static int write_alert_level(struct monitor *monitor)
 	return 0;
 }
 
+static void tx_power_read_cb(guint8 status, const guint8 *pdu, guint16 plen,
+							gpointer user_data)
+{
+	uint8_t value;
+	int vlen;
+
+	if (status != 0) {
+		DBG("Tx Power Level read failed: %s", att_ecode2str(status));
+		return;
+	}
+
+	if (!dec_read_resp(pdu, plen, &value, &vlen)) {
+		DBG("Protocol error");
+		return;
+	}
+
+	DBG("Tx Power Level: %02x", (int8_t) value);
+}
+
+static void tx_power_handle_cb(GSList *characteristics, guint8 status,
+							gpointer user_data)
+{
+	struct monitor *monitor = user_data;
+	struct att_char *chr;
+
+	if (status) {
+		error("Discover Tx Power handle: %s", att_ecode2str(status));
+		return;
+	}
+
+	chr = characteristics->data;
+	monitor->txpowerhandle = chr->value_handle;
+
+	DBG("Tx Power handle: 0x%04x", monitor->txpowerhandle);
+
+	gatt_read_char(monitor->attrib, monitor->txpowerhandle, 0,
+							tx_power_read_cb, monitor);
+}
+
+static void read_tx_power(struct monitor *monitor)
+{
+	struct att_range *txpower = monitor->txpower;
+	bt_uuid_t uuid;
+
+	if (monitor->txpowerhandle != 0) {
+		gatt_read_char(monitor->attrib, monitor->txpowerhandle, 0,
+						tx_power_read_cb, monitor);
+		return;
+	}
+
+	bt_uuid16_create(&uuid, POWER_LEVEL_CHR_UUID);
+
+	gatt_discover_char(monitor->attrib, txpower->start, txpower->end,
+				&uuid, tx_power_handle_cb, monitor);
+}
+
 static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 {
 	struct monitor *monitor = user_data;
@@ -183,6 +241,9 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 
 	if (monitor->enabled.linkloss)
 		write_alert_level(monitor);
+
+	if (monitor->enabled.pathloss)
+		read_tx_power(monitor);
 }
 
 static void attio_disconnected_cb(gpointer user_data)
-- 
1.7.6


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

* [PATCH BlueZ 02/11] Add Immediate Alert handle discovery
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 01/11] Add read remote Tx Power Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 03/11] Write Immediate Alert if necessary Claudio Takahasi
                   ` (9 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

---
 proximity/monitor.c |   34 ++++++++++++++++++++++++++++++++++
 1 files changed, 34 insertions(+), 0 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index e9cf2e7..64e9690 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -73,6 +73,7 @@ struct monitor {
 	uint16_t linklosshandle;	/* Link Loss Characteristic
 					 * Value Handle */
 	uint16_t txpowerhandle;		/* Tx Characteristic Value Handle */
+	uint16_t immediatehandle;	/* Immediate Alert Value Handle */
 	guint attioid;
 };
 
@@ -233,6 +234,35 @@ static void read_tx_power(struct monitor *monitor)
 				&uuid, tx_power_handle_cb, monitor);
 }
 
+static void immediate_handle_cb(GSList *characteristics, guint8 status,
+							gpointer user_data)
+{
+	struct monitor *monitor = user_data;
+	struct att_char *chr;
+
+	if (status) {
+		error("Discover Immediate Alert handle: %s",
+						att_ecode2str(status));
+		return;
+	}
+
+	chr = characteristics->data;
+	monitor->immediatehandle = chr->value_handle;
+
+	DBG("Immediate Alert handle: 0x%04x", monitor->immediatehandle);
+}
+
+static void discover_immediate_handle(struct monitor *monitor)
+{
+	struct att_range *immediate = monitor->immediate;
+	bt_uuid_t uuid;
+
+	bt_uuid16_create(&uuid, ALERT_LEVEL_CHR_UUID);
+
+	gatt_discover_char(monitor->attrib, immediate->start, immediate->end,
+					&uuid, immediate_handle_cb, monitor);
+}
+
 static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 {
 	struct monitor *monitor = user_data;
@@ -244,6 +274,10 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 
 	if (monitor->enabled.pathloss)
 		read_tx_power(monitor);
+
+	if (monitor->immediatehandle == 0 &&
+			(monitor->enabled.pathloss || monitor->enabled.findme))
+		discover_immediate_handle(monitor);
 }
 
 static void attio_disconnected_cb(gpointer user_data)
-- 
1.7.6


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

* [PATCH BlueZ 03/11] Write Immediate Alert if necessary
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 01/11] Add read remote Tx Power Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 02/11] Add Immediate Alert handle discovery Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 04/11] Emit PropertyChanged after writting alert Claudio Takahasi
                   ` (8 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Immediate Alert value needs to be written when the connection is
established.
---
 proximity/monitor.c |   24 ++++++++++++++++++++----
 1 files changed, 20 insertions(+), 4 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index 64e9690..824a87c 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -68,6 +68,7 @@ struct monitor {
 	struct att_range *immediate;
 	struct enabled enabled;
 	char *linklosslevel;		/* Link Loss Alert Level */
+	char *fallbacklevel;		/* Immediate fallback alert level */
 	char *immediatelevel;		/* Immediate Alert Level */
 	char *signallevel;		/* Path Loss RSSI level */
 	uint16_t linklosshandle;	/* Link Loss Characteristic
@@ -234,6 +235,16 @@ static void read_tx_power(struct monitor *monitor)
 				&uuid, tx_power_handle_cb, monitor);
 }
 
+static void write_immediate_alert(struct monitor *monitor)
+{
+	uint8_t value = str2level(monitor->immediatelevel);
+
+	gatt_write_cmd(monitor->attrib, monitor->immediatehandle, &value, 1,
+								NULL, NULL);
+	g_free(monitor->fallbacklevel);
+	monitor->fallbacklevel = NULL;
+}
+
 static void immediate_handle_cb(GSList *characteristics, guint8 status,
 							gpointer user_data)
 {
@@ -275,9 +286,11 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 	if (monitor->enabled.pathloss)
 		read_tx_power(monitor);
 
-	if (monitor->immediatehandle == 0 &&
-			(monitor->enabled.pathloss || monitor->enabled.findme))
-		discover_immediate_handle(monitor);
+	if (monitor->immediatehandle == 0) {
+		if(monitor->enabled.pathloss || monitor->enabled.findme)
+			discover_immediate_handle(monitor);
+	} else if (monitor->fallbacklevel)
+		write_immediate_alert(monitor);
 }
 
 static void attio_disconnected_cb(gpointer user_data)
@@ -336,7 +349,10 @@ static DBusMessage *set_immediate_alert(DBusConnection *conn, DBusMessage *msg,
 	if (g_strcmp0(monitor->immediatelevel, level) == 0)
 		return dbus_message_new_method_return(msg);
 
-	g_free(monitor->immediatelevel);
+	/* Previous Immediate Alert level if connection/write fails */
+	g_free(monitor->fallbacklevel);
+	monitor->fallbacklevel = monitor->immediatelevel;
+
 	monitor->immediatelevel = g_strdup(level);
 
 	emit_property_changed(conn, path, PROXIMITY_INTERFACE,
-- 
1.7.6


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

* [PATCH BlueZ 04/11] Emit PropertyChanged after writting alert
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
                   ` (2 preceding siblings ...)
  2011-08-08 18:46 ` [PATCH BlueZ 03/11] Write Immediate Alert if necessary Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 05/11] Write Immediate Alert after discovering handle Claudio Takahasi
                   ` (7 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Wait sending write characteristic value for Immediate Alert before
sending a PropertyChanged signal in the Proximity Monitor. Applied
to FindMe Profile and Path Loss service when the threshold is reached.
---
 proximity/monitor.c |   25 +++++++++++++++++--------
 1 files changed, 17 insertions(+), 8 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index 824a87c..2d405be 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -63,6 +63,7 @@ enum {
 struct monitor {
 	struct btd_device *device;
 	GAttrib *attrib;
+	DBusConnection *conn;
 	struct att_range *linkloss;
 	struct att_range *txpower;
 	struct att_range *immediate;
@@ -235,14 +236,25 @@ static void read_tx_power(struct monitor *monitor)
 				&uuid, tx_power_handle_cb, monitor);
 }
 
+static void immediate_written(gpointer user_data)
+{
+	struct monitor *monitor = user_data;
+	const char *path = device_get_path(monitor->device);
+
+	g_free(monitor->fallbacklevel);
+	monitor->fallbacklevel = NULL;
+
+	emit_property_changed(monitor->conn, path, PROXIMITY_INTERFACE,
+				"ImmediateAlertLevel",
+				DBUS_TYPE_STRING, &monitor->immediatelevel);
+}
+
 static void write_immediate_alert(struct monitor *monitor)
 {
 	uint8_t value = str2level(monitor->immediatelevel);
 
 	gatt_write_cmd(monitor->attrib, monitor->immediatehandle, &value, 1,
-								NULL, NULL);
-	g_free(monitor->fallbacklevel);
-	monitor->fallbacklevel = NULL;
+						immediate_written, monitor);
 }
 
 static void immediate_handle_cb(GSList *characteristics, guint8 status,
@@ -341,7 +353,6 @@ static DBusMessage *set_immediate_alert(DBusConnection *conn, DBusMessage *msg,
 						const char *level, void *data)
 {
 	struct monitor *monitor = data;
-	const gchar *path = device_get_path(monitor->device);
 
 	if (!level_is_valid(level))
 		return btd_error_invalid_args(msg);
@@ -355,10 +366,6 @@ static DBusMessage *set_immediate_alert(DBusConnection *conn, DBusMessage *msg,
 
 	monitor->immediatelevel = g_strdup(level);
 
-	emit_property_changed(conn, path, PROXIMITY_INTERFACE,
-					"ImmediateAlertLevel",
-					DBUS_TYPE_STRING, &level);
-
 	return dbus_message_new_method_return(msg);
 }
 
@@ -464,6 +471,7 @@ static void monitor_destroy(gpointer user_data)
 	if (monitor->attrib)
 		g_attrib_unref(monitor->attrib);
 
+	dbus_connection_unref(monitor->conn);
 	btd_device_unref(monitor->device);
 	g_free(monitor->linkloss);
 	g_free(monitor->immediate);
@@ -490,6 +498,7 @@ int monitor_register(DBusConnection *conn, struct btd_device *device,
 
 	monitor = g_new0(struct monitor, 1);
 	monitor->device = btd_device_ref(device);
+	monitor->conn = dbus_connection_ref(conn);
 	monitor->linklosslevel = (level ? : g_strdup("none"));
 	monitor->signallevel = g_strdup("unknown");
 
-- 
1.7.6


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

* [PATCH BlueZ 05/11] Write Immediate Alert after discovering handle
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
                   ` (3 preceding siblings ...)
  2011-08-08 18:46 ` [PATCH BlueZ 04/11] Emit PropertyChanged after writting alert Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 06/11] Request connection when writting Immediate alert Claudio Takahasi
                   ` (6 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Write the Immediate Alert level characteristic if there is a pending
alert value to be written after discovering the characteristic handle.
---
 proximity/monitor.c |    3 +++
 1 files changed, 3 insertions(+), 0 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index 2d405be..95e0f8e 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -273,6 +273,9 @@ static void immediate_handle_cb(GSList *characteristics, guint8 status,
 	monitor->immediatehandle = chr->value_handle;
 
 	DBG("Immediate Alert handle: 0x%04x", monitor->immediatehandle);
+
+	if (monitor->fallbacklevel)
+		write_immediate_alert(monitor);
 }
 
 static void discover_immediate_handle(struct monitor *monitor)
-- 
1.7.6


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

* [PATCH BlueZ 06/11] Request connection when writting Immediate alert
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
                   ` (4 preceding siblings ...)
  2011-08-08 18:46 ` [PATCH BlueZ 05/11] Write Immediate Alert after discovering handle Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 07/11] Reset Immediate Alert after 5 seconds Claudio Takahasi
                   ` (5 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

When Link and Path Loss are disabled, ATT connection callback will
be registered. Client using FindMe Profile needs to request ATT
connection before writting the Immediate Alert characteristic value.
---
 proximity/monitor.c |   12 ++++++++++++
 1 files changed, 12 insertions(+), 0 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index 95e0f8e..5664c4b 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -369,6 +369,18 @@ static DBusMessage *set_immediate_alert(DBusConnection *conn, DBusMessage *msg,
 
 	monitor->immediatelevel = g_strdup(level);
 
+	/*
+	 * Means that Link/Path Loss are disabled or there is a pending
+	 * writting for Find Me(Immediate Alert characteristic value).
+	 * If enabled, Path Loss always registers a connection callback
+	 * when the Proximity Monitor starts.
+	 */
+	if (monitor->attioid == 0)
+		monitor->attioid = btd_device_add_attio_callback(monitor->device,
+							attio_connected_cb,
+							attio_disconnected_cb,
+							monitor);
+
 	return dbus_message_new_method_return(msg);
 }
 
-- 
1.7.6


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

* [PATCH BlueZ 07/11] Reset Immediate Alert after 5 seconds
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
                   ` (5 preceding siblings ...)
  2011-08-08 18:46 ` [PATCH BlueZ 06/11] Request connection when writting Immediate alert Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 08/11] Reset the Immediate Alert at disconnection Claudio Takahasi
                   ` (4 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Add implementation specific timeout. Immediate Alert is set to "none"
after the timeout. Reporter can also implement a timeout for reseting
the alert level. Alert level is a write only and not notifiable
characteristic. In the timeout source, the Proximity Monitor writes
"none" in the Reporter and notifies the D-Bus clients that the alert
level has changed.
---
 proximity/monitor.c |   39 +++++++++++++++++++++++++++++++++++++++
 1 files changed, 39 insertions(+), 0 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index 5664c4b..f765824 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -54,6 +54,8 @@
 #define ALERT_LEVEL_CHR_UUID 0x2A06
 #define POWER_LEVEL_CHR_UUID 0x2A07
 
+#define IMMEDIATE_TIMEOUT	5
+
 enum {
 	ALERT_NONE = 0,
 	ALERT_MILD,
@@ -76,6 +78,7 @@ struct monitor {
 					 * Value Handle */
 	uint16_t txpowerhandle;		/* Tx Characteristic Value Handle */
 	uint16_t immediatehandle;	/* Immediate Alert Value Handle */
+	guint immediateto;		/* Reset Immediate Alert to "none" */
 	guint attioid;
 };
 
@@ -236,6 +239,31 @@ static void read_tx_power(struct monitor *monitor)
 				&uuid, tx_power_handle_cb, monitor);
 }
 
+static gboolean immediate_timeout(gpointer user_data)
+{
+	struct monitor *monitor = user_data;
+	const char *path = device_get_path(monitor->device);
+
+	monitor->immediateto = 0;
+
+	if (g_strcmp0(monitor->immediatelevel, "none") == 0)
+		return FALSE;
+
+	if (monitor->attrib) {
+		uint8_t value = ALERT_NONE;
+		gatt_write_cmd(monitor->attrib, monitor->immediatehandle,
+				&value, 1, NULL, NULL);
+	}
+
+	g_free(monitor->immediatelevel);
+	monitor->immediatelevel = g_strdup("none");
+	emit_property_changed(monitor->conn, path, PROXIMITY_INTERFACE,
+					"ImmediateAlertLevel", DBUS_TYPE_STRING,
+					&monitor->immediatelevel);
+
+	return FALSE;
+}
+
 static void immediate_written(gpointer user_data)
 {
 	struct monitor *monitor = user_data;
@@ -247,6 +275,9 @@ static void immediate_written(gpointer user_data)
 	emit_property_changed(monitor->conn, path, PROXIMITY_INTERFACE,
 				"ImmediateAlertLevel",
 				DBUS_TYPE_STRING, &monitor->immediatelevel);
+
+	monitor->immediateto = g_timeout_add_seconds(IMMEDIATE_TIMEOUT,
+						immediate_timeout, monitor);
 }
 
 static void write_immediate_alert(struct monitor *monitor)
@@ -363,6 +394,11 @@ static DBusMessage *set_immediate_alert(DBusConnection *conn, DBusMessage *msg,
 	if (g_strcmp0(monitor->immediatelevel, level) == 0)
 		return dbus_message_new_method_return(msg);
 
+	if (monitor->immediateto) {
+		g_source_remove(monitor->immediateto);
+		monitor->immediateto = 0;
+	}
+
 	/* Previous Immediate Alert level if connection/write fails */
 	g_free(monitor->fallbacklevel);
 	monitor->fallbacklevel = monitor->immediatelevel;
@@ -480,6 +516,9 @@ static void monitor_destroy(gpointer user_data)
 {
 	struct monitor *monitor = user_data;
 
+	if (monitor->immediateto)
+		g_source_remove(monitor->immediateto);
+
 	if (monitor->attioid)
 		btd_device_remove_attio_callback(monitor->device,
 						monitor->attioid);
-- 
1.7.6


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

* [PATCH BlueZ 08/11] Reset the Immediate Alert at disconnection
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
                   ` (6 preceding siblings ...)
  2011-08-08 18:46 ` [PATCH BlueZ 07/11] Reset Immediate Alert after 5 seconds Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 09/11] Set default value for ImmediateAlertLevel Claudio Takahasi
                   ` (3 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Reporter will turn off the alert when the link is disconnected. At the
Proximity Monitor side, the Immediate Alert level should also follow
the same logic.
---
 proximity/monitor.c |   16 ++++++++++++++++
 1 files changed, 16 insertions(+), 0 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index f765824..58557e9 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -342,9 +342,25 @@ static void attio_connected_cb(GAttrib *attrib, gpointer user_data)
 static void attio_disconnected_cb(gpointer user_data)
 {
 	struct monitor *monitor = user_data;
+	const char *path = device_get_path(monitor->device);
 
 	g_attrib_unref(monitor->attrib);
 	monitor->attrib = NULL;
+
+	if (monitor->immediateto == 0)
+		return;
+
+	g_source_remove(monitor->immediateto);
+	monitor->immediateto = 0;
+
+	if (g_strcmp0(monitor->immediatelevel, "none") == 0)
+		return;
+
+	g_free(monitor->immediatelevel);
+	monitor->immediatelevel = g_strdup("none");
+	emit_property_changed(monitor->conn, path, PROXIMITY_INTERFACE,
+					"ImmediateAlertLevel", DBUS_TYPE_STRING,
+					&monitor->immediatelevel);
 }
 
 static gboolean level_is_valid(const char *level)
-- 
1.7.6


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

* [PATCH BlueZ 09/11] Set default value for ImmediateAlertLevel
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
                   ` (7 preceding siblings ...)
  2011-08-08 18:46 ` [PATCH BlueZ 08/11] Reset the Immediate Alert at disconnection Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 10/11] Write Immediate Alert if connected Claudio Takahasi
                   ` (2 subsequent siblings)
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

Alert Level of the Immediate Alert service is write only. "none" can be
the default value since the alert/alarm is disabled at disconnection.
---
 proximity/monitor.c |    1 +
 1 files changed, 1 insertions(+), 0 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index 58557e9..2133ad7 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -571,6 +571,7 @@ int monitor_register(DBusConnection *conn, struct btd_device *device,
 	monitor->conn = dbus_connection_ref(conn);
 	monitor->linklosslevel = (level ? : g_strdup("none"));
 	monitor->signallevel = g_strdup("unknown");
+	monitor->immediatelevel = g_strdup("none");
 
 	if (g_dbus_register_interface(conn, path,
 				PROXIMITY_INTERFACE,
-- 
1.7.6


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

* [PATCH BlueZ 10/11] Write Immediate Alert if connected
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
                   ` (8 preceding siblings ...)
  2011-08-08 18:46 ` [PATCH BlueZ 09/11] Set default value for ImmediateAlertLevel Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-08 18:46 ` [PATCH BlueZ 11/11] Fix wrong alert value for ImmediateAlertLevel Claudio Takahasi
  2011-08-09  7:24 ` [PATCH BlueZ 00/11] Immediate Alert patches Johan Hedberg
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

When SetProperty for ImmediateAlertLevel is called, write operation to
update the characteristic in the Immediate Alert Service can be sent
if the connection is established.
---
 proximity/monitor.c |    2 ++
 1 files changed, 2 insertions(+), 0 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index 2133ad7..b59e7a0 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -432,6 +432,8 @@ static DBusMessage *set_immediate_alert(DBusConnection *conn, DBusMessage *msg,
 							attio_connected_cb,
 							attio_disconnected_cb,
 							monitor);
+	else if (monitor->attrib)
+		write_immediate_alert(monitor);
 
 	return dbus_message_new_method_return(msg);
 }
-- 
1.7.6


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

* [PATCH BlueZ 11/11] Fix wrong alert value for ImmediateAlertLevel
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
                   ` (9 preceding siblings ...)
  2011-08-08 18:46 ` [PATCH BlueZ 10/11] Write Immediate Alert if connected Claudio Takahasi
@ 2011-08-08 18:46 ` Claudio Takahasi
  2011-08-09  7:24 ` [PATCH BlueZ 00/11] Immediate Alert patches Johan Hedberg
  11 siblings, 0 replies; 13+ messages in thread
From: Claudio Takahasi @ 2011-08-08 18:46 UTC (permalink / raw)
  To: linux-bluetooth; +Cc: Claudio Takahasi

GetProperties method is returning wrong value for ImmediateAlertLevel.
Bug introduced by ffd21d4027cd91d864857d2d4c3664b3087c5e0a
---
 proximity/monitor.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index b59e7a0..55d3985 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -463,7 +463,7 @@ static DBusMessage *get_properties(DBusConnection *conn,
 
 	if (monitor->enabled.findme || monitor->enabled.pathloss)
 		dict_append_entry(&dict, "ImmediateAlertLevel",
-				DBUS_TYPE_STRING, &monitor->linklosslevel);
+				DBUS_TYPE_STRING, &monitor->immediatelevel);
 
 	if (monitor->enabled.pathloss)
 		dict_append_entry(&dict, "SignalLevel",
-- 
1.7.6


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

* Re: [PATCH BlueZ 00/11] Immediate Alert patches
  2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
                   ` (10 preceding siblings ...)
  2011-08-08 18:46 ` [PATCH BlueZ 11/11] Fix wrong alert value for ImmediateAlertLevel Claudio Takahasi
@ 2011-08-09  7:24 ` Johan Hedberg
  11 siblings, 0 replies; 13+ messages in thread
From: Johan Hedberg @ 2011-08-09  7:24 UTC (permalink / raw)
  To: Claudio Takahasi; +Cc: linux-bluetooth

Hi Claudio,

On Mon, Aug 08, 2011, Claudio Takahasi wrote:
> Dependency: none. RSSI threshold monitor patches are not required for
> this patch series.
> 
> Implementation of D-Bus properties and GATT/ATT operations related to
> alert level of the Immediate alert service.
> 
> Bruna Moreira (1):
>   Add read remote Tx Power
> 
> Claudio Takahasi (10):
>   Add Immediate Alert handle discovery
>   Write Immediate Alert if necessary
>   Emit PropertyChanged after writting alert
>   Write Immediate Alert after discovering handle
>   Request connection when writting Immediate alert
>   Reset Immediate Alert after 5 seconds
>   Reset the Immediate Alert at disconnection
>   Set default value for ImmediateAlertLevel
>   Write Immediate Alert if connected
>   Fix wrong alert value for ImmediateAlertLevel
> 
>  proximity/monitor.c |  205 +++++++++++++++++++++++++++++++++++++++++++++++++--
>  1 files changed, 199 insertions(+), 6 deletions(-)

Applied. Thanks.

Johan

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

end of thread, other threads:[~2011-08-09  7:24 UTC | newest]

Thread overview: 13+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2011-08-08 18:46 [PATCH BlueZ 00/11] Immediate Alert patches Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 01/11] Add read remote Tx Power Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 02/11] Add Immediate Alert handle discovery Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 03/11] Write Immediate Alert if necessary Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 04/11] Emit PropertyChanged after writting alert Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 05/11] Write Immediate Alert after discovering handle Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 06/11] Request connection when writting Immediate alert Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 07/11] Reset Immediate Alert after 5 seconds Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 08/11] Reset the Immediate Alert at disconnection Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 09/11] Set default value for ImmediateAlertLevel Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 10/11] Write Immediate Alert if connected Claudio Takahasi
2011-08-08 18:46 ` [PATCH BlueZ 11/11] Fix wrong alert value for ImmediateAlertLevel Claudio Takahasi
2011-08-09  7:24 ` [PATCH BlueZ 00/11] Immediate Alert patches Johan Hedberg

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