* [PATCH BlueZ 1/2] Fix wrong write GATT-subprocedure for Link Loss @ 2011-10-04 17:22 Claudio Takahasi 2011-10-04 17:22 ` [PATCH BlueZ 2/2] Emit LinkLossAlertLevel after writing the alert Claudio Takahasi 2011-10-05 8:18 ` [PATCH BlueZ 1/2] Fix wrong write GATT-subprocedure for Link Loss Johan Hedberg 0 siblings, 2 replies; 3+ messages in thread From: Claudio Takahasi @ 2011-10-04 17:22 UTC (permalink / raw) To: linux-bluetooth; +Cc: Claudio Takahasi 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 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* [PATCH BlueZ 2/2] Emit LinkLossAlertLevel after writing the alert 2011-10-04 17:22 [PATCH BlueZ 1/2] Fix wrong write GATT-subprocedure for Link Loss Claudio Takahasi @ 2011-10-04 17:22 ` Claudio Takahasi 2011-10-05 8:18 ` [PATCH BlueZ 1/2] Fix wrong write GATT-subprocedure for Link Loss Johan Hedberg 1 sibling, 0 replies; 3+ messages in thread From: Claudio Takahasi @ 2011-10-04 17:22 UTC (permalink / raw) To: linux-bluetooth; +Cc: Claudio Takahasi --- proximity/monitor.c | 17 ++++++++++------- 1 files changed, 10 insertions(+), 7 deletions(-) diff --git a/proximity/monitor.c b/proximity/monitor.c index d40d376..29ae425 100644 --- a/proximity/monitor.c +++ b/proximity/monitor.c @@ -142,6 +142,10 @@ static uint8_t str2level(const char *level) static void linkloss_written(guint8 status, const guint8 *pdu, guint16 plen, gpointer user_data) { + struct monitor *monitor = user_data; + struct btd_device *device = monitor->device; + const char *path = device_get_path(device); + if (status != 0) { error("Link Loss Write Request failed: %s", att_ecode2str(status)); @@ -154,6 +158,10 @@ static void linkloss_written(guint8 status, const guint8 *pdu, guint16 plen, } DBG("Link Loss Alert Level written"); + + emit_property_changed(monitor->conn, path, + PROXIMITY_INTERFACE, "LinkLossAlertLevel", + DBUS_TYPE_STRING, &monitor->linklosslevel); } static void char_discovered_cb(GSList *characteristics, guint8 status, @@ -175,7 +183,7 @@ static void char_discovered_cb(GSList *characteristics, guint8 status, monitor->linklosshandle = chr->value_handle; gatt_write_char(monitor->attrib, monitor->linklosshandle, &value, 1, - linkloss_written, NULL); + linkloss_written, monitor); } static int write_alert_level(struct monitor *monitor) @@ -187,7 +195,7 @@ static int write_alert_level(struct monitor *monitor) uint8_t value = str2level(monitor->linklosslevel); gatt_write_char(monitor->attrib, monitor->linklosshandle, - &value, 1, linkloss_written, NULL); + &value, 1, linkloss_written, monitor); return 0; } @@ -397,7 +405,6 @@ static DBusMessage *set_link_loss_alert(DBusConnection *conn, DBusMessage *msg, { struct monitor *monitor = data; struct btd_device *device = monitor->device; - const char *path = device_get_path(device); bdaddr_t sba, dba; if (!level_is_valid(level)) @@ -414,10 +421,6 @@ static DBusMessage *set_link_loss_alert(DBusConnection *conn, DBusMessage *msg, write_proximity_config(&sba, &dba, "LinkLossAlertLevel", level); - emit_property_changed(conn, path, - PROXIMITY_INTERFACE, "LinkLossAlertLevel", - DBUS_TYPE_STRING, &monitor->linklosslevel); - if (monitor->attrib) write_alert_level(monitor); -- 1.7.7 ^ permalink raw reply related [flat|nested] 3+ messages in thread
* Re: [PATCH BlueZ 1/2] Fix wrong write GATT-subprocedure for Link Loss 2011-10-04 17:22 [PATCH BlueZ 1/2] Fix wrong write GATT-subprocedure for Link Loss Claudio Takahasi 2011-10-04 17:22 ` [PATCH BlueZ 2/2] Emit LinkLossAlertLevel after writing the alert Claudio Takahasi @ 2011-10-05 8:18 ` Johan Hedberg 1 sibling, 0 replies; 3+ messages in thread From: Johan Hedberg @ 2011-10-05 8:18 UTC (permalink / raw) To: Claudio Takahasi; +Cc: linux-bluetooth Hi Claudio, On Tue, Oct 04, 2011, Claudio Takahasi wrote: > 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(-) Both patches applied. Thanks. Johan ^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2011-10-05 8:18 UTC | newest] Thread overview: 3+ messages (download: mbox.gz follow: Atom feed -- links below jump to the message on this page -- 2011-10-04 17:22 [PATCH BlueZ 1/2] Fix wrong write GATT-subprocedure for Link Loss Claudio Takahasi 2011-10-04 17:22 ` [PATCH BlueZ 2/2] Emit LinkLossAlertLevel after writing the alert Claudio Takahasi 2011-10-05 8:18 ` [PATCH BlueZ 1/2] Fix wrong write GATT-subprocedure for Link Loss Johan Hedberg
This is a public inbox, see mirroring instructions for how to clone and mirror all data and code used for this inbox