summaryrefslogtreecommitdiff
path: root/dexcom_reader/dexcom_dumper.py
diff options
context:
space:
mode:
Diffstat (limited to 'dexcom_reader/dexcom_dumper.py')
-rwxr-xr-xdexcom_reader/dexcom_dumper.py18
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
17from optparse import OptionParser 17from optparse import OptionParser
18 18
19G5_IS_DEFAULT = True 19DEFAULT_RECEIVER_TYPE = "g5m"
20 20
21def get_dracos_host(): 21def 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
28parser = OptionParser() 28parser = OptionParser()
29parser.add_option("--g4", action="store_false", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G4 instead of Dexcom G5") 29parser.add_option("--g4", const="g4", action="store_const", dest="receiver_type", help="use Dexcom G4 instead of Dexcom G5")
30parser.add_option("--g5", action="store_true", dest="g5", default=G5_IS_DEFAULT, help="use Dexcom G5 instead of Dexcom G4") 30parser.add_option("--g5", const="g5", action="store_const", dest="receiver_type", help="use Dexcom G5 instead of Dexcom G4")
31parser.add_option("--g5m", const="g5m", action="store_const", dest="receiver_type", help="use Dexcom G5 Mobile instead of Dexcom G4")
31 32
32parser.add_option("-a", "--all", action="store_const", dest="command", const="dump_everything", help="dump all available records") 33parser.add_option("-a", "--all", action="store_const", dest="command", const="dump_everything", help="dump all available records")
33parser.add_option("-p", "--poll", action="store_const", dest="command", const="poll", help="poll for latest CGM record") 34parser.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
47if not options.receiver_type:
48 options.receiver_type = DEFAULT_RECEIVER_TYPE
49
46command = options.command or "dump_cgm" 50command = options.command or "dump_cgm"
47VERBOSE = options.verbose 51VERBOSE = options.verbose
48HUMAN = options.human 52HUMAN = options.human
@@ -63,7 +67,10 @@ if options.num_records <= 0:
63 options.num_records = None 67 options.num_records = None
64 68
65def get_dexcom_reader(): 69def 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():