From 7075275de1b4abcb56ed305500fb799406a8854e Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sun, 7 Jan 2018 00:19:16 +0000 Subject: otverioiq: implement full parsing of the response structure. The TidePool driver does not implement meal comment and it does not validate the full message. I checked the flags with the trace and they match the values in otverio2015. --- glucometerutils/drivers/otverioiq.py | 22 +++++++++++++++++++--- 1 file changed, 19 insertions(+), 3 deletions(-) diff --git a/glucometerutils/drivers/otverioiq.py b/glucometerutils/drivers/otverioiq.py index 453ec00..f7baa85 100644 --- a/glucometerutils/drivers/otverioiq.py +++ b/glucometerutils/drivers/otverioiq.py @@ -80,11 +80,21 @@ _READ_RECORD_REQUEST = construct.Struct( 'record_id' / construct.Int16ul, ) +_MEAL_FLAG = { + common.Meal.NONE: 0x00, + common.Meal.BEFORE: 0x01, + common.Meal.AFTER: 0x02, +} + _READING_RESPONSE = construct.Struct( lifescan_binary_protocol.COMMAND_SUCCESS, 'timestamp' / construct_extras.Timestamp(construct.Int32ul), 'value' / construct.Int32ul, - 'control' / construct.Byte, # Unknown value + 'control_test' / construct.Flag, + construct.Padding(1), # unknown + 'meal' / construct.SymmetricMapping( + construct.Byte, _MEAL_FLAG), + cosntruct.Padding(2), # unknown ) @@ -190,10 +200,16 @@ class Device(serial.SerialDevice): response = self._send_request( _READ_RECORD_REQUEST, {'record_id': record_id}, _READING_RESPONSE) + if response.control_test: + logging.debug('control solution test, ignoring.') + return None + return common.GlucoseReading( - response.timestamp, float(response.value)) + response.timestamp, float(response.value), meal=response.meal) def get_readings(self): record_count = self._get_reading_count() for record_id in range(record_count): - yield self._get_reading(record_id) + reading = self._get_reading(record_id) + if reading: + yield reading -- cgit v1.2.3