Diff between 726dc13a33ef1a73854521f9306536904b48eb93 and 3cda922eead61ba0a862924bf49246d81e9b1669

Changed Files

File Additions Deletions Status
thermometer/thermometer.c +8 -2 modified

Full Patch

diff --git a/thermometer/thermometer.c b/thermometer/thermometer.c
index e78d250..e8da73f 100644
--- a/thermometer/thermometer.c
+++ b/thermometer/thermometer.c
@@ -1072,12 +1072,18 @@ static void proc_measurement(struct thermometer *t, const uint8_t *pdu,
 		m.suptime = FALSE;
 
 	if (flags & TEMP_TYPE) {
-		if (len < 16) {
+		uint8_t index;
+
+		if (m.suptime && len >= 16)
+			index = 15;
+		else if (!m.suptime && len >= 9)
+			index = 9;
+		else {
 			DBG("Can't get temperature type");
 			return;
 		}
 
-		type = temptype2str(pdu[15]);
+		type = temptype2str(pdu[index]);
 	} else if (t->has_type)
 		type = temptype2str(t->type);
 	else {