From: Santiago Carot-Nemesio <sancane@gmail.com>
To: linux-bluetooth@vger.kernel.org
Cc: Santiago Carot-Nemesio <sancane@gmail.com>
Subject: [PATCH 2/8] Get valid range descriptor if it is supported
Date: Mon, 24 Oct 2011 19:04:02 +0200 [thread overview]
Message-ID: <1319475848-4171-3-git-send-email-sancane@gmail.com> (raw)
In-Reply-To: <1319475848-4171-2-git-send-email-sancane@gmail.com>
---
thermometer/thermometer.c | 39 ++++++++++++++++++++++++++++++++++++++-
1 files changed, 38 insertions(+), 1 deletions(-)
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index 4008bb9..9c9a861 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -157,6 +157,42 @@ static void change_property(struct thermometer *t, const gchar *name,
DBG("%s is not a thermometer property", name);
}
+static void valid_range_desc_cb(guint8 status, const guint8 *pdu, guint16 len,
+ gpointer user_data)
+{
+ struct descriptor *desc = user_data;
+ uint8_t value[ATT_MAX_MTU];
+ uint16_t max, min;
+ int vlen;
+
+ if (status != 0) {
+ DBG("Valid Range descriptor read failed: %s",
+ att_ecode2str(status));
+ return;
+ }
+
+ if (!dec_read_resp(pdu, len, value, &vlen)) {
+ DBG("Protocol error\n");
+ return;
+ }
+
+ if (vlen < 4) {
+ DBG("Invalid range received");
+ return;
+ }
+
+ min = att_get_u16(&value[0]);
+ max = att_get_u16(&value[2]);
+
+ if (min == 0 || min > max) {
+ DBG("Invalid range");
+ return;
+ }
+
+ change_property(desc->ch->t, "Maximum", &max);
+ change_property(desc->ch->t, "Minimum", &min);
+}
+
static void process_thermometer_desc(struct descriptor *desc)
{
struct characteristic *ch = desc->ch;
@@ -188,7 +224,8 @@ static void process_thermometer_desc(struct descriptor *desc)
if (bt_uuid_cmp(&desc->uuid, &btuuid) == 0 && g_strcmp0(ch->attr.uuid,
MEASUREMENT_INTERVAL_UUID) == 0) {
- /* TODO: Process Measurement Interval */
+ gatt_read_char(ch->t->attrib, desc->handle, 0,
+ valid_range_desc_cb, desc);
return;
}
--
1.7.6.1
next prev parent reply other threads:[~2011-10-24 17:04 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2011-10-24 17:04 Health Thermometer Profile Santiago Carot-Nemesio
2011-10-24 17:04 ` [PATCH 1/8] Process characteristic descriptors in the thermometer service Santiago Carot-Nemesio
2011-10-24 17:04 ` Santiago Carot-Nemesio [this message]
2011-10-24 17:04 ` [PATCH 3/8] Implement D-Bus register watcher function Santiago Carot-Nemesio
2011-10-24 17:04 ` [PATCH 4/8] Implement D-Bus unregister " Santiago Carot-Nemesio
2011-10-24 17:04 ` [PATCH 5/8] Enable final measurement indications when first watcher is enabled Santiago Carot-Nemesio
2011-10-24 17:04 ` [PATCH 6/8] Disable final measurements indication when last watcher is removed Santiago Carot-Nemesio
2011-10-24 17:04 ` [PATCH 7/8] Manage watcher's disconnections from the bus Santiago Carot-Nemesio
2011-10-24 17:04 ` [PATCH 8/8] Implement D-Bus get properties function Santiago Carot-Nemesio
2011-11-02 9:59 ` Health Thermometer Profile Santiago Carot
2011-11-02 9:59 ` Johan Hedberg
-- strict thread matches above, loose matches on Subject: below --
2011-10-20 9:46 Santiago Carot-Nemesio
2011-10-20 9:46 ` [PATCH 1/8] Process characteristic descriptors in thermometer service Santiago Carot-Nemesio
2011-10-20 9:46 ` [PATCH 2/8] Get valid range descriptor if it is supported Santiago Carot-Nemesio
2011-10-20 11:07 ` Anderson Lizardo
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=1319475848-4171-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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.