diff options
Diffstat (limited to 'dexcom_reader/dexcom_dumper.py')
-rwxr-xr-x | dexcom_reader/dexcom_dumper.py | 18 |
1 files changed, 13 insertions, 5 deletions
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(): |