From: Anderson Lizardo <anderson.lizardo@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Anderson Lizardo <anderson.lizardo@openbossa.org>
Subject: [PATCH BlueZ 3/3] thermometer: Fix re-enabling notification/indication on reconnection
Date: Tue, 14 Feb 2012 13:52:25 -0400 [thread overview]
Message-ID: <1329241945-32414-3-git-send-email-anderson.lizardo@openbossa.org> (raw)
In-Reply-To: <1329241945-32414-1-git-send-email-anderson.lizardo@openbossa.org>
If a result callback is not specified for gatt_write_char() it is
assumed that Write Command will be used. This is not valid for
Characteristic Descriptors, which only support Write Request.
---
thermometer/thermometer.c | 35 +++++++++++++++++++++--------------
1 files changed, 21 insertions(+), 14 deletions(-)
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index 7906d84..d09c63c 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -331,6 +331,17 @@ static void valid_range_desc_cb(guint8 status, const guint8 *pdu, guint16 len,
change_property(desc->ch->t, "Minimum", &min);
}
+static void measurement_cb(guint8 status, const guint8 *pdu,
+ guint16 len, gpointer user_data)
+{
+ char *msg = user_data;
+
+ if (status != 0)
+ error("%s failed", msg);
+
+ g_free(msg);
+}
+
static void process_thermometer_desc(struct descriptor *desc)
{
struct characteristic *ch = desc->ch;
@@ -342,6 +353,7 @@ static void process_thermometer_desc(struct descriptor *desc)
if (bt_uuid_cmp(&desc->uuid, &btuuid) == 0) {
uint8_t atval[2];
uint16_t val;
+ char *msg;
if (g_strcmp0(ch->attr.uuid,
TEMPERATURE_MEASUREMENT_UUID) == 0) {
@@ -349,21 +361,27 @@ static void process_thermometer_desc(struct descriptor *desc)
return;
val = ATT_CLIENT_CHAR_CONF_INDICATION;
+ msg = g_strdup("Enable Temperature Measurement "
+ "indication");
} else if (g_strcmp0(ch->attr.uuid,
INTERMEDIATE_TEMPERATURE_UUID) == 0) {
if (g_slist_length(ch->t->iwatchers) == 0)
return;
val = ATT_CLIENT_CHAR_CONF_NOTIFICATION;
+ msg = g_strdup("Enable Intermediate Temperature "
+ "notification");
} else if (g_strcmp0(ch->attr.uuid,
- MEASUREMENT_INTERVAL_UUID) == 0)
+ MEASUREMENT_INTERVAL_UUID) == 0) {
val = ATT_CLIENT_CHAR_CONF_INDICATION;
- else
+ msg = g_strdup("Enable Measurement Interval "
+ "indication");
+ } else
goto done;
att_put_u16(val, atval);
gatt_write_char(ch->t->attrib, desc->handle, atval, 2,
- NULL, NULL);
+ measurement_cb, msg);
return;
}
@@ -655,17 +673,6 @@ static DBusMessage *set_property(DBusConnection *conn, DBusMessage *msg,
return write_attr_interval(t, msg, value);
}
-static void measurement_cb(guint8 status, const guint8 *pdu,
- guint16 len, gpointer user_data)
-{
- char *msg = user_data;
-
- if (status != 0)
- error("%s failed", msg);
-
- g_free(msg);
-}
-
static void enable_final_measurement(struct thermometer *t)
{
struct characteristic *ch;
--
1.7.5.4
next prev parent reply other threads:[~2012-02-14 17:52 UTC|newest]
Thread overview: 14+ messages / expand[flat|nested] mbox.gz Atom feed top
2012-02-14 17:52 [PATCH BlueZ 1/3] thermometer: Fix device driver probe Anderson Lizardo
2012-02-14 17:52 ` [PATCH BlueZ 2/3] thermometer: Fix handling of missing Temperature Type Anderson Lizardo
2012-02-15 8:50 ` Santiago Carot
2012-02-15 10:41 ` Anderson Lizardo
2012-02-15 11:06 ` Santiago Carot
2012-02-15 11:53 ` Anderson Lizardo
2012-02-15 12:49 ` Anderson Lizardo
2012-02-14 17:52 ` Anderson Lizardo [this message]
2012-02-15 9:03 ` [PATCH BlueZ 3/3] thermometer: Fix re-enabling notification/indication on reconnection Santiago Carot
2012-02-15 10:44 ` Anderson Lizardo
2012-02-15 12:38 ` [PATCH v2 BlueZ 1/3] thermometer: Fix device driver probe Anderson Lizardo
2012-02-15 12:38 ` [PATCH v2 BlueZ 2/3] thermometer: Fix handling of missing Temperature Type Anderson Lizardo
2012-02-15 12:38 ` [PATCH v2 BlueZ 3/3] thermometer: Fix re-enabling notification/indication on reconnection Anderson Lizardo
2012-02-16 13:13 ` [PATCH v2 BlueZ 1/3] thermometer: Fix device driver probe Johan Hedberg
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=1329241945-32414-3-git-send-email-anderson.lizardo@openbossa.org \
--to=anderson.lizardo@openbossa.org \
--cc=linux-bluetooth@vger.kernel.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
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).