From 4d44849cfc752cdc9872ab53409a43696edce36e Mon Sep 17 00:00:00 2001 From: Andrew Cady Date: Thu, 10 Jan 2019 15:03:42 -0500 Subject: add support for Dexcom G5 Mobile and make it default --- dexcom_reader/dexcom_dumper.py | 18 +++++++++++++----- 1 file changed, 13 insertions(+), 5 deletions(-) (limited to 'dexcom_reader/dexcom_dumper.py') 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 from optparse import OptionParser -G5_IS_DEFAULT = True +DEFAULT_RECEIVER_TYPE = "g5m" def get_dracos_host(): res = subprocess.check_output([ @@ -26,8 +26,9 @@ def get_dracos_host(): return res.decode('utf-8') parser = OptionParser() -parser.add_option("--g4", action="store_false", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G4 instead of Dexcom G5") -parser.add_option("--g5", action="store_true", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G5 instead of Dexcom G4") +parser.add_option("--g4", const="g4", action="store_const", dest="receiver_type", help="use Dexcom G4 instead of Dexcom G5") +parser.add_option("--g5", const="g5", action="store_const", dest="receiver_type", help="use Dexcom G5 instead of Dexcom G4") +parser.add_option("--g5m", const="g5m", action="store_const", dest="receiver_type", help="use Dexcom G5 Mobile instead of Dexcom G4") parser.add_option("-a", "--all", action="store_const", dest="command", const="dump_everything", help="dump all available records") 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 (options, args) = parser.parse_args() +if not options.receiver_type: + options.receiver_type = DEFAULT_RECEIVER_TYPE + command = options.command or "dump_cgm" VERBOSE = options.verbose HUMAN = options.human @@ -63,7 +67,10 @@ if options.num_records <= 0: options.num_records = None def get_dexcom_reader(): - if options.g5: + if options.receiver_type == "g5m": + dd = readdata.DexcomG5Mobile.FindDevice() + return readdata.DexcomG5Mobile(dd) + elif options.receiver_type == "g5": dd = readdata.DexcomG5.FindDevice() return readdata.DexcomG5(dd) else: @@ -228,7 +235,8 @@ def poll(): global dr if dr: dr.Disconnect() - dr = readdata.DexcomG5(devicer.device.device_node) + drf = readdata.DexcomG5 if options.receiver_type == "g5" else readdata.DexcomG5Mobile + dr = drf(devicer.device.device_node) print("Device opened.") while devicer.have(): -- cgit v1.2.3