diff options
-rw-r--r-- | dexcom_reader/database_records.py | 3 | ||||
-rwxr-xr-x | dexcom_reader/dexcom_dumper.py | 18 | ||||
-rw-r--r-- | dexcom_reader/readdata.py | 10 |
3 files changed, 26 insertions, 5 deletions
diff --git a/dexcom_reader/database_records.py b/dexcom_reader/database_records.py index fa09bea..eb06d88 100644 --- a/dexcom_reader/database_records.py +++ b/dexcom_reader/database_records.py | |||
@@ -338,4 +338,7 @@ class G5EGVRecord (EGVRecord): | |||
338 | def full_trend(self): | 338 | def full_trend(self): |
339 | return self.data[12] | 339 | return self.data[12] |
340 | 340 | ||
341 | class G5MobileEGVRecord (EGVRecord): | ||
342 | FORMAT = '<2IHxxxxxxxxxcxxxH' | ||
343 | |||
341 | 344 | ||
diff --git a/dexcom_reader/dexcom_dumper.py b/dexcom_reader/dexcom_dumper.py index c4db06a..b0a52e2 100755 --- a/dexcom_reader/dexcom_dumper.py +++ b/dexcom_reader/dexcom_dumper.py | |||
@@ -16,7 +16,7 @@ from database_records import GenericTimestampedRecord, EGVRecord, EventRecord | |||
16 | 16 | ||
17 | from optparse import OptionParser | 17 | from optparse import OptionParser |
18 | 18 | ||
19 | G5_IS_DEFAULT = True | 19 | DEFAULT_RECEIVER_TYPE = "g5m" |
20 | 20 | ||
21 | def get_dracos_host(): | 21 | def get_dracos_host(): |
22 | res = subprocess.check_output([ | 22 | res = subprocess.check_output([ |
@@ -26,8 +26,9 @@ def get_dracos_host(): | |||
26 | return res.decode('utf-8') | 26 | return res.decode('utf-8') |
27 | 27 | ||
28 | parser = OptionParser() | 28 | parser = OptionParser() |
29 | parser.add_option("--g4", action="store_false", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G4 instead of Dexcom G5") | 29 | parser.add_option("--g4", const="g4", action="store_const", dest="receiver_type", help="use Dexcom G4 instead of Dexcom G5") |
30 | parser.add_option("--g5", action="store_true", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G5 instead of Dexcom G4") | 30 | parser.add_option("--g5", const="g5", action="store_const", dest="receiver_type", help="use Dexcom G5 instead of Dexcom G4") |
31 | parser.add_option("--g5m", const="g5m", action="store_const", dest="receiver_type", help="use Dexcom G5 Mobile instead of Dexcom G4") | ||
31 | 32 | ||
32 | parser.add_option("-a", "--all", action="store_const", dest="command", const="dump_everything", help="dump all available records") | 33 | parser.add_option("-a", "--all", action="store_const", dest="command", const="dump_everything", help="dump all available records") |
33 | parser.add_option("-p", "--poll", action="store_const", dest="command", const="poll", help="poll for latest CGM record") | 34 | parser.add_option("-p", "--poll", action="store_const", dest="command", const="poll", help="poll for latest CGM record") |
@@ -43,6 +44,9 @@ parser.add_option("--client", action="store_true", dest="client", help="act as c | |||
43 | 44 | ||
44 | (options, args) = parser.parse_args() | 45 | (options, args) = parser.parse_args() |
45 | 46 | ||
47 | if not options.receiver_type: | ||
48 | options.receiver_type = DEFAULT_RECEIVER_TYPE | ||
49 | |||
46 | command = options.command or "dump_cgm" | 50 | command = options.command or "dump_cgm" |
47 | VERBOSE = options.verbose | 51 | VERBOSE = options.verbose |
48 | HUMAN = options.human | 52 | HUMAN = options.human |
@@ -63,7 +67,10 @@ if options.num_records <= 0: | |||
63 | options.num_records = None | 67 | options.num_records = None |
64 | 68 | ||
65 | def get_dexcom_reader(): | 69 | def get_dexcom_reader(): |
66 | if options.g5: | 70 | if options.receiver_type == "g5m": |
71 | dd = readdata.DexcomG5Mobile.FindDevice() | ||
72 | return readdata.DexcomG5Mobile(dd) | ||
73 | elif options.receiver_type == "g5": | ||
67 | dd = readdata.DexcomG5.FindDevice() | 74 | dd = readdata.DexcomG5.FindDevice() |
68 | return readdata.DexcomG5(dd) | 75 | return readdata.DexcomG5(dd) |
69 | else: | 76 | else: |
@@ -228,7 +235,8 @@ def poll(): | |||
228 | global dr | 235 | global dr |
229 | if dr: | 236 | if dr: |
230 | dr.Disconnect() | 237 | dr.Disconnect() |
231 | dr = readdata.DexcomG5(devicer.device.device_node) | 238 | drf = readdata.DexcomG5 if options.receiver_type == "g5" else readdata.DexcomG5Mobile |
239 | dr = drf(devicer.device.device_node) | ||
232 | 240 | ||
233 | print("Device opened.") | 241 | print("Device opened.") |
234 | while devicer.have(): | 242 | while devicer.have(): |
diff --git a/dexcom_reader/readdata.py b/dexcom_reader/readdata.py index 84033f0..ded95d3 100644 --- a/dexcom_reader/readdata.py +++ b/dexcom_reader/readdata.py | |||
@@ -362,6 +362,16 @@ class DexcomG5 (Dexcom): | |||
362 | 'SENSOR_DATA': database_records.SensorRecord, | 362 | 'SENSOR_DATA': database_records.SensorRecord, |
363 | } | 363 | } |
364 | 364 | ||
365 | class DexcomG5Mobile (Dexcom): | ||
366 | PARSER_MAP = { | ||
367 | 'USER_EVENT_DATA': database_records.EventRecord, | ||
368 | 'METER_DATA': database_records.G5MeterRecord, | ||
369 | 'CAL_SET': database_records.Calibration, | ||
370 | 'INSERTION_TIME': database_records.G5InsertionRecord, | ||
371 | 'EGV_DATA': database_records.G5MobileEGVRecord, | ||
372 | 'SENSOR_DATA': database_records.SensorRecord, | ||
373 | } | ||
374 | |||
365 | def GetDevice (port, G5=False): | 375 | def GetDevice (port, G5=False): |
366 | if G5: | 376 | if G5: |
367 | return DexcomG5(port) | 377 | return DexcomG5(port) |