aboutsummaryrefslogtreecommitdiffstats
path: root/thermometer
diff options
context:
space:
mode:
authorSantiago Carot-Nemesio <sancane@gmail.com>2011-12-09 19:19:00 +0100
committerJohan Hedberg <johan.hedberg@intel.com>2011-12-15 13:23:37 +0200
commitc275bde366db4da6319043f048e1add572dc9dbc (patch)
tree7fcbe31457de64d00730e1a7eec907884b633fe1 /thermometer
parent563ef8324c6994e0383138802349490d8168af30 (diff)
downloadbluez-c275bde366db4da6319043f048e1add572dc9dbc.tar.gz
bluez-c275bde366db4da6319043f048e1add572dc9dbc.tar.xz
bluez-c275bde366db4da6319043f048e1add572dc9dbc.zip
thermometer: Configure C.C.C descriptor during thermometer configuration
This patch enables notification/indication in GATT server if there are any watcher regitered for measurements when the thermometer is configured.
Diffstat (limited to 'thermometer')
-rw-r--r--thermometer/thermometer.c25
1 files changed, 17 insertions, 8 deletions
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index cacf579a..64ac26fb 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -340,21 +340,30 @@ static void process_thermometer_desc(struct descriptor *desc)
bt_uuid16_create(&btuuid, GATT_CLIENT_CHARAC_CFG_UUID);
if (bt_uuid_cmp(&desc->uuid, &btuuid) == 0) {
+ uint8_t atval[2];
+ uint16_t val;
+
if (g_strcmp0(ch->attr.uuid,
TEMPERATURE_MEASUREMENT_UUID) == 0) {
- /* TODO: Check if we have to enable it */
- DBG("C.C.C in Temperature Measurement");
+ if (g_slist_length(ch->t->fwatchers) == 0)
+ return;
+
+ val = ATT_CLIENT_CHAR_CONF_INDICATION;
} else if (g_strcmp0(ch->attr.uuid,
INTERMEDIATE_TEMPERATURE_UUID) == 0) {
- /* TODO: Check if we have to enable it */
- DBG("C.C.C in Intermediate Temperature");
+ if (g_slist_length(ch->t->iwatchers) == 0)
+ return;
+
+ val = ATT_CLIENT_CHAR_CONF_NOTIFICATION;
} else if (g_strcmp0(ch->attr.uuid,
- MEASUREMENT_INTERVAL_UUID) == 0) {
- /* TODO: Enable indications */
- DBG("C.C.C in Measurement Interval");
- } else
+ MEASUREMENT_INTERVAL_UUID) == 0)
+ val = ATT_CLIENT_CHAR_CONF_INDICATION;
+ else
goto done;
+ att_put_u16(val, atval);
+ gatt_write_char(ch->t->attrib, desc->handle, atval, 2,
+ NULL, NULL);
return;
}