linux-bluetooth.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Anderson Lizardo <anderson.lizardo@openbossa.org>
To: linux-bluetooth@vger.kernel.org
Cc: Anderson Lizardo <anderson.lizardo@openbossa.org>
Subject: [PATCH v2 BlueZ 2/3] thermometer: Fix handling of missing Temperature Type
Date: Wed, 15 Feb 2012 08:38:18 -0400	[thread overview]
Message-ID: <1329309499-14454-2-git-send-email-anderson.lizardo@openbossa.org> (raw)
In-Reply-To: <1329309499-14454-1-git-send-email-anderson.lizardo@openbossa.org>

According to HTS 1.0 (Table 3.1, and Sections 3.1.1.4 and 3.2), the
Temperature Type Characteristic is optional. The only restriction is
that it shall not be present if the Temperature Type is non-static, for
which case the "Temperature Type" field shall be present on the
Temperature Measurement Characteristic value.

Given there is no default value specified when the Temperature Type is
static and unknown, the "Type" entry for MeasurementReceived() on the
Thermometer API was made optional.
---
 doc/thermometer-api.txt   |    3 ++-
 test/test-thermometer     |    3 ++-
 thermometer/thermometer.c |   11 +++--------
 3 files changed, 7 insertions(+), 10 deletions(-)

diff --git a/doc/thermometer-api.txt b/doc/thermometer-api.txt
index 6392d39..2271270 100644
--- a/doc/thermometer-api.txt
+++ b/doc/thermometer-api.txt
@@ -103,7 +103,8 @@ Methods		void MeasurementReceived(dict measure)
 			data. The time value is expressed in seconds since epoch.
 			The value represented is (mantissa) x (10**exponent)
 			See foot note for special values when treating with
-			health devices.
+			health devices. The Type entry is only present if the
+			measurement type is known. Otherwise, it is undefined.
 
 			Dict is defined as below:
 			{
diff --git a/test/test-thermometer b/test/test-thermometer
index 5f9742a..bf3b83e 100755
--- a/test/test-thermometer
+++ b/test/test-thermometer
@@ -24,7 +24,8 @@ class Watcher(dbus.service.Object):
 		if measure.has_key("Time"):
 			print "Time: ", measure["Time"]
 
-		print "Type: ", measure["Type"]
+		if measure.has_key("Type"):
+			print "Type: ", measure["Type"]
 
 def property_changed(name, value):
 
diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index 9bf9881..7aa621f 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -1086,15 +1086,10 @@ static void proc_measurement(struct thermometer *t, const uint8_t *pdu,
 		type = temptype2str(pdu[index]);
 	} else if (t->has_type)
 		type = temptype2str(t->type);
-	else {
-		DBG("Can't get temperature type");
-		return;
-	}
-
-	if (type == NULL)
-		return;
+	else
+		type = NULL;
 
-	m.type = g_strdup(type);
+	m.type = type ? g_strdup(type) : NULL;
 	m.value = final ? "Final" : "Intermediate";
 
 	recv_measurement(t, &m);
-- 
1.7.5.4


  reply	other threads:[~2012-02-15 12:38 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2012-02-14 17:52 [PATCH BlueZ 1/3] thermometer: Fix device driver probe Anderson Lizardo
2012-02-14 17:52 ` [PATCH BlueZ 2/3] thermometer: Fix handling of missing Temperature Type Anderson Lizardo
2012-02-15  8:50   ` Santiago Carot
2012-02-15 10:41     ` Anderson Lizardo
2012-02-15 11:06       ` Santiago Carot
2012-02-15 11:53         ` Anderson Lizardo
2012-02-15 12:49         ` Anderson Lizardo
2012-02-14 17:52 ` [PATCH BlueZ 3/3] thermometer: Fix re-enabling notification/indication on reconnection Anderson Lizardo
2012-02-15  9:03   ` Santiago Carot
2012-02-15 10:44     ` Anderson Lizardo
2012-02-15 12:38 ` [PATCH v2 BlueZ 1/3] thermometer: Fix device driver probe Anderson Lizardo
2012-02-15 12:38   ` Anderson Lizardo [this message]
2012-02-15 12:38   ` [PATCH v2 BlueZ 3/3] thermometer: Fix re-enabling notification/indication on reconnection Anderson Lizardo
2012-02-16 13:13   ` [PATCH v2 BlueZ 1/3] thermometer: Fix device driver probe 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=1329309499-14454-2-git-send-email-anderson.lizardo@openbossa.org \
    --to=anderson.lizardo@openbossa.org \
    --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).