From: Santiago Carot-Nemesio <sancane@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Santiago Carot-Nemesio <sancane@gmail.com>
Subject: [PATCH 2/6] thermometer.c: Confiure C.C.C descriptor during the thermometer configuration
Date: Fri, 9 Dec 2011 19:19:00 +0100 [thread overview]
Message-ID: <1323454744-14589-3-git-send-email-sancane@gmail.com> (raw)
In-Reply-To: <1323454744-14589-2-git-send-email-sancane@gmail.com>
This patch enables notification/indication in GATT server if there
are any watcher regitered for measurements when the thermometer is
configured.
---
thermometer/thermometer.c | 25 +++++++++++++++++--------
1 files changed, 17 insertions(+), 8 deletions(-)
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index 2a0fb0f..d175800 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;
}
--
1.7.8
next prev parent reply other threads:[~2011-12-09 18:19 UTC|newest]
Thread overview: 8+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-12-09 18:18 Health Thermometer Profile patches Santiago Carot-Nemesio
2011-12-09 18:18 ` [PATCH 1/6] thermometer.c: Implement SetProperty D-Bus method Santiago Carot-Nemesio
2011-12-09 18:19 ` Santiago Carot-Nemesio [this message]
2011-12-09 18:19 ` [PATCH 3/6] thermometer.c: Process measurement interval indications Santiago Carot-Nemesio
2011-12-09 18:19 ` [PATCH 4/6] thermometer.c: Fix possible null pointer deference Santiago Carot-Nemesio
2011-12-09 18:19 ` [PATCH 5/6] thermometer.c: Fix bad read operation when time stamp is not provided Santiago Carot-Nemesio
2011-12-09 18:19 ` [PATCH 6/6] thermometer.c: Use system types instead of GLIB ones Santiago Carot-Nemesio
2011-12-15 11:29 ` Health Thermometer Profile patches 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=1323454744-14589-3-git-send-email-sancane@gmail.com \
--to=sancane@gmail.com \
--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).