aboutsummaryrefslogtreecommitdiffstats
path: root/thermometer
diff options
context:
space:
mode:
authorSantiago Carot-Nemesio <sancane@gmail.com>2011-10-24 19:04:06 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2011-11-02 11:55:26 +0200
commit29db85bf38ab26b459159dcf42d842f35c6e13a2 (patch)
treec420691e33411a2ddd5d139556472c8082af4d55 /thermometer
parente09be5e2706a241501706452b8a058bfb2262967 (diff)
downloadbluez-29db85bf38ab26b459159dcf42d842f35c6e13a2.tar.gz
bluez-29db85bf38ab26b459159dcf42d842f35c6e13a2.tar.xz
bluez-29db85bf38ab26b459159dcf42d842f35c6e13a2.zip
Disable final measurements indication when last watcher is removed
Diffstat (limited to 'thermometer')
-rw-r--r--thermometer/thermometer.c25
1 files changed, 24 insertions, 1 deletions
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index ffcdf6e9..9513fcdf 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -526,7 +526,30 @@ static void enable_final_measurement(struct thermometer *t)
static void disable_final_measurement(struct thermometer *t)
{
- /* TODO: disable final measurements */
+ struct characteristic *ch;
+ struct descriptor *desc;
+ bt_uuid_t btuuid;
+ uint8_t atval[2];
+ gchar *msg;
+
+ ch = get_characteristic(t, TEMPERATURE_MEASUREMENT_UUID);
+ if (ch == NULL) {
+ DBG("Temperature measurement characteristic not found");
+ return;
+ }
+
+ bt_uuid16_create(&btuuid, GATT_CLIENT_CHARAC_CFG_UUID);
+ desc = get_descriptor(ch, &btuuid);
+ if (desc == NULL) {
+ DBG("Client characteristic configuration descriptor not found");
+ return;
+ }
+
+ atval[0] = 0x00;
+ atval[1] = 0x00;
+ msg = g_strdup("Disable final measurement");
+ gatt_write_char(t->attrib, desc->handle, atval, 2,
+ final_measurement_cb, msg);
}
static void watcher_exit(DBusConnection *conn, void *user_data)