From 349b1c794b68fe2dcaad4cd9cf28d09a1d56ee17 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Diego=20Elio=20Petten=C3=B2?= Date: Sat, 6 Jan 2018 21:10:11 +0000 Subject: lifescan_binary_protocol: factor out glucose unit mappings. The values are the same between all models sharing this protocol, even though the full reply message isn't. --- glucometerutils/support/lifescan_binary_protocol.py | 9 +++++++++ 1 file changed, 9 insertions(+) (limited to 'glucometerutils/support') diff --git a/glucometerutils/support/lifescan_binary_protocol.py b/glucometerutils/support/lifescan_binary_protocol.py index 68b030d..0143cd4 100644 --- a/glucometerutils/support/lifescan_binary_protocol.py +++ b/glucometerutils/support/lifescan_binary_protocol.py @@ -14,6 +14,7 @@ __license__ = 'MIT' import construct +from glucometerutils import common from glucometerutils.support import construct_extras from glucometerutils.support import lifescan @@ -50,3 +51,11 @@ PACKET = construct.Struct( VERIO_TIMESTAMP = construct_extras.Timestamp( construct.Int32ul, epoch=946684800) # 2010-01-01 00:00 + +_GLUCOSE_UNIT_MAPPING_TABLE = { + common.Unit.MG_DL: 0x00, + common.Unit.MMOL_L: 0x01, +} + +GLUCOSE_UNIT = construct.SymmetricMapping( + construct.Byte, _GLUCOSE_UNIT_MAPPING_TABLE) -- cgit v1.2.3