From e289def741325b87881b4556bf600b77108bccba Mon Sep 17 00:00:00 2001 From: Andrzej Kaczmarek Date: Fri, 9 Nov 2012 09:55:52 +0100 Subject: [PATCH] thermometer: Always write CCC value when connecting This patch ensures that CCC values for Intermediate Temperature and Termperature Measurement are always written when connecting to device. This is to i.e. disable notifications and/or indications in case they are already enabled (reconnection scenario) but we don't have watcher registered so it's pointless for remote to send us data. --- profiles/thermometer/thermometer.c | 24 ++++++++++++++---------- 1 file changed, 14 insertions(+), 10 deletions(-) diff --git a/profiles/thermometer/thermometer.c b/profiles/thermometer/thermometer.c index f832fb407..78dfacb22 100644 --- a/profiles/thermometer/thermometer.c +++ b/profiles/thermometer/thermometer.c @@ -550,19 +550,23 @@ static void process_thermometer_desc(struct characteristic *ch, uint16_t uuid, if (g_strcmp0(ch->uuid, TEMPERATURE_MEASUREMENT_UUID) == 0) { ch->t->measurement_ccc_handle = handle; - if (g_slist_length(ch->t->tadapter->fwatchers) == 0) - return; - - val = GATT_CLIENT_CHARAC_CFG_IND_BIT; - msg = g_strdup("Enable Temperature Measurement indication"); + if (g_slist_length(ch->t->tadapter->fwatchers) == 0) { + val = 0x0000; + msg = g_strdup("Disable Temperature Measurement ind"); + } else { + val = GATT_CLIENT_CHARAC_CFG_IND_BIT; + msg = g_strdup("Enable Temperature Measurement ind"); + } } else if (g_strcmp0(ch->uuid, INTERMEDIATE_TEMPERATURE_UUID) == 0) { ch->t->intermediate_ccc_handle = handle; - if (g_slist_length(ch->t->tadapter->iwatchers) == 0) - return; - - val = GATT_CLIENT_CHARAC_CFG_NOTIF_BIT; - msg = g_strdup("Enable Intermediate Temperature notification"); + if (g_slist_length(ch->t->tadapter->iwatchers) == 0) { + val = 0x0000; + msg = g_strdup("Disable Intermediate Temperature noti"); + } else { + val = GATT_CLIENT_CHARAC_CFG_NOTIF_BIT; + msg = g_strdup("Enable Intermediate Temperature noti"); + } } else if (g_strcmp0(ch->uuid, MEASUREMENT_INTERVAL_UUID) == 0) { val = GATT_CLIENT_CHARAC_CFG_IND_BIT; msg = g_strdup("Enable Measurement Interval indication"); -- 2.47.3