aboutsummaryrefslogtreecommitdiffstats
path: root/thermometer
diff options
context:
space:
mode:
authorSantiago Carot-Nemesio <sancane@gmail.com>2011-10-24 19:04:02 +0200
committerJohan Hedberg <johan.hedberg@intel.com>2011-11-02 11:54:46 +0200
commit5ab1c52a1424594b59a8a14475f0be3a6156574c (patch)
tree1d6c4c62eb18c4f66b8d29adfd817341cf61262b /thermometer
parentd7fecaa17fc78b78ae064d581051386d2833c7ae (diff)
downloadbluez-5ab1c52a1424594b59a8a14475f0be3a6156574c.tar.gz
bluez-5ab1c52a1424594b59a8a14475f0be3a6156574c.tar.xz
bluez-5ab1c52a1424594b59a8a14475f0be3a6156574c.zip
Get valid range descriptor if it is supported
Diffstat (limited to 'thermometer')
-rw-r--r--thermometer/thermometer.c39
1 files changed, 38 insertions, 1 deletions
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index c05e3825..3ded9c3d 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -162,6 +162,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;
@@ -193,7 +229,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;
}