[PATCH BlueZ 1/2] Fix wrong write GATT-subprocedure for Link Loss

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



According to Link Loss Service specification, Write Characteristic
Value sub-procedure should be used to change the Alert Level.
---
 proximity/monitor.c |   25 +++++++++++++++++++++----
 1 files changed, 21 insertions(+), 4 deletions(-)

diff --git a/proximity/monitor.c b/proximity/monitor.c
index 884e66d..d40d376 100644
--- a/proximity/monitor.c
+++ b/proximity/monitor.c
@@ -139,6 +139,23 @@ static uint8_t str2level(const char *level)
 	return ALERT_NONE;
 }
 
+static void linkloss_written(guint8 status, const guint8 *pdu, guint16 plen,
+							gpointer user_data)
+{
+	if (status != 0) {
+		error("Link Loss Write Request failed: %s",
+							att_ecode2str(status));
+		return;
+	}
+
+	if (!dec_write_resp(pdu, plen)) {
+		error("Link Loss Write Request: protocol error");
+		return;
+	}
+
+	DBG("Link Loss Alert Level written");
+}
+
 static void char_discovered_cb(GSList *characteristics, guint8 status,
 							gpointer user_data)
 {
@@ -157,8 +174,8 @@ static void char_discovered_cb(GSList *characteristics, guint8 status,
 	chr = characteristics->data;
 	monitor->linklosshandle = chr->value_handle;
 
-	gatt_write_cmd(monitor->attrib, monitor->linklosshandle, &value, 1,
-								NULL, NULL);
+	gatt_write_char(monitor->attrib, monitor->linklosshandle, &value, 1,
+						linkloss_written, NULL);
 }
 
 static int write_alert_level(struct monitor *monitor)
@@ -169,8 +186,8 @@ static int write_alert_level(struct monitor *monitor)
 	if (monitor->linklosshandle) {
 		uint8_t value = str2level(monitor->linklosslevel);
 
-		gatt_write_cmd(monitor->attrib, monitor->linklosshandle,
-							&value, 1, NULL, NULL);
+		gatt_write_char(monitor->attrib, monitor->linklosshandle,
+					&value, 1, linkloss_written, NULL);
 		return 0;
 	}
 
-- 
1.7.7

--
To unsubscribe from this list: send the line "unsubscribe linux-bluetooth" in
the body of a message to majordomo@xxxxxxxxxxxxxxx
More majordomo info at  http://vger.kernel.org/majordomo-info.html


[Index of Archives]     [Bluez Devel]     [Linux Wireless Networking]     [Linux Wireless Personal Area Networking]     [Linux ATH6KL]     [Linux USB Devel]     [Linux Media Drivers]     [Linux Audio Users]     [Linux Kernel]     [Linux SCSI]     [Big List of Linux Books]

  Powered by Linux