summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDiego Elio Pettenò <flameeyes@flameeyes.eu>2018-01-06 22:10:11 +0100
committerDiego Elio Pettenò <flameeyes@flameeyes.eu>2018-01-06 22:10:11 +0100
commit349b1c794b68fe2dcaad4cd9cf28d09a1d56ee17 (patch)
tree7716b39a0979eb897ab15738fbac3a7609ad1c64
parentlifescan_binary_protocol: create a new module to support LifeScan drivers. (diff)
downloadglucometerutils-349b1c794b68fe2dcaad4cd9cf28d09a1d56ee17.tar
glucometerutils-349b1c794b68fe2dcaad4cd9cf28d09a1d56ee17.tar.gz
glucometerutils-349b1c794b68fe2dcaad4cd9cf28d09a1d56ee17.tar.bz2
glucometerutils-349b1c794b68fe2dcaad4cd9cf28d09a1d56ee17.tar.lz
glucometerutils-349b1c794b68fe2dcaad4cd9cf28d09a1d56ee17.tar.xz
glucometerutils-349b1c794b68fe2dcaad4cd9cf28d09a1d56ee17.tar.zst
glucometerutils-349b1c794b68fe2dcaad4cd9cf28d09a1d56ee17.zip
-rw-r--r--glucometerutils/drivers/otultraeasy.py7
-rw-r--r--glucometerutils/drivers/otverio2015.py8
-rw-r--r--glucometerutils/support/lifescan_binary_protocol.py9
3 files changed, 11 insertions, 13 deletions
diff --git a/glucometerutils/drivers/otultraeasy.py b/glucometerutils/drivers/otultraeasy.py
index 0063ec1..fe7e4ae 100644
--- a/glucometerutils/drivers/otultraeasy.py
+++ b/glucometerutils/drivers/otultraeasy.py
@@ -66,15 +66,10 @@ _DATETIME_RESPONSE = construct.Struct(
_GLUCOSE_UNIT_REQUEST = construct.Const(
b'\x05\x09\x02\x09\x00\x00\x00\x00')
-_GLUCOSE_MAPPING = {
- common.Unit.MG_DL: 0x00,
- common.Unit.MMOL_L: 0x01,
-}
_GLUCOSE_UNIT_RESPONSE = construct.Struct(
_COMMAND_SUCCESS,
- 'unit' / construct.SymmetricMapping(
- construct.Byte, _GLUCOSE_MAPPING),
+ 'unit' / lifescan_binary_protocol.GLUCOSE_UNIT,
construct.Padding(3),
)
diff --git a/glucometerutils/drivers/otverio2015.py b/glucometerutils/drivers/otverio2015.py
index d0b8a9c..9aff4d2 100644
--- a/glucometerutils/drivers/otverio2015.py
+++ b/glucometerutils/drivers/otverio2015.py
@@ -64,15 +64,9 @@ _READ_PARAMETER_REQUEST = construct.Struct(
construct.Byte, unit=0x04),
)
-_GLUCOSE_MAPPING = {
- common.Unit.MG_DL: 0x00,
- common.Unit.MMOL_L: 0x01,
-}
-
_READ_UNIT_RESPONSE = construct.Struct(
construct.Const(b'\x03\x06'), # different from _COMMAND_SUCCESS
- 'unit' / construct.SymmetricMapping(
- construct.Byte, _GLUCOSE_MAPPING),
+ 'unit' / lifescan_binary_protocol.GLUCOSE_UNIT,
construct.Padding(3),
)
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)