diff options
author | Anderson Lizardo <anderson.lizardo@openbossa.org> | 2012-02-15 08:38:19 -0400 |
---|---|---|
committer | Johan Hedberg <johan.hedberg@intel.com> | 2012-02-16 15:11:56 +0200 |
commit | 2898d58bfc248865227d327bd299c9282271db5b (patch) | |
tree | b9f50b4977aac25f82acd058fd72b300a0e63f70 /thermometer | |
parent | dfa888e54f6b2fc48e123de2c58a364615fd92ee (diff) | |
download | bluez-2898d58bfc248865227d327bd299c9282271db5b.tar.gz bluez-2898d58bfc248865227d327bd299c9282271db5b.tar.xz bluez-2898d58bfc248865227d327bd299c9282271db5b.zip |
thermometer: Fix re-enabling notification/indication on reconnection
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.
Diffstat (limited to 'thermometer')
-rw-r--r-- | thermometer/thermometer.c | 35 |
1 files changed, 21 insertions, 14 deletions
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c index 7aa621f6..3cc2454e 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; |