Skip to content

Commit 78b103b

Browse files
author
Brian Bosh
committed
Merge branch 'master' of github.com:altintx/chromadex
2 parents 3a6267e + a775b28 commit 78b103b

File tree

2 files changed

+58
-35
lines changed

2 files changed

+58
-35
lines changed

README.md

Lines changed: 9 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,27 +1,22 @@
11
##chromadex
2-
Download Dexcom data on almost any platform Chrome runs on. (Developed and tested on Mac OSX). A good deal of this data is corrupt.
3-
4-
###Changelog
5-
mongolabconfig.json has dropped "baseUri", "user" and "password" and added "collection" and "database." So If you're integrated against Nightscout be sure to update that file.
2+
Download Dexcom data on almost any platform Chrome runs on. (Developed and tested on Mac OSX). A good deal of this data is corrupt. It should work on Windows if [Dexcom Studio](http://dexcom.com/dexcom-studio) is installed, but other platforms should work more magically.
63

74
##Don't use it for treatment. Seriously. A lot of this data is wrong. Not a little wrong. OMG WTF out of left field wrong.
85

96
###Install
107
1. Get code in folder
118
2. Open a terminal and CD to that folder
12-
3. Install bower if you haven't already (npm install bower)
13-
4. Install bower dependencies (bower install)
14-
5. You're done with your terminal. Give yourself a pat on the back.
15-
6. Go to chrome://extensions
16-
7. Check developer mode
17-
8. Load unpacked extension
18-
9. Pick your folder
19-
10. If you use NightScout- Dupe FOLDER/mongoconfig.sample.json to FOLDER/mongoconfig.json. Your API key is the important part. IF YOU DON'T USE NIGHTSCOUT YOU CAN SKIP THIS STEP.
20-
11. If you use DIYPS- Dupe FOLDER/diypsconfig.sample.json to /diypsconfig.json. Add chromeext.php into DIYPS directory and point diypsconfig.json's endpoint to that resulting URL. IF YOU DON'T USE DIYPS YOU CAN SKIP THIS STEP.
9+
3. Install dependencies (npm install)
10+
4. You're done with your terminal. Give yourself a pat on the back.
11+
5. Go to chrome://extensions
12+
6. Check developer mode
13+
7. Load unpacked extension
14+
8. Pick your folder
2115

2216
###Use
2317
1. Plug in your Dexcom
24-
2. Go to chrome://extensions
18+
2. Magic happens
19+
2. If magic did not happen, open chrome://extensions
2520
3. Click launch
2621

2722
Lots of steps and right now. Some times you get no data back, usually preceded by completely inaccurate graphs- if that happens, press the Reset button. This'll wipe out all the data it's accumulated. Doesn't seem like you really need to unplug/replug anymore.

app/dexcom.js

Lines changed: 49 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -54,36 +54,64 @@ define(function () {
5454
port: null,
5555
buffer: [],
5656
connect: function(serialport) {
57+
return new Promise(function(resolve, reject) {
58+
chrome.serial.getDevices(function(ports) {
59+
for (var i=0; i<ports.length; i++) {
60+
var port = ports[i];
61+
console.log("Checking port for dexcom device ID: %s", port.path);
62+
if (port.vendorId == 8867 && port.productId == 71) {
63+
console.debug("Found dexcom serial port at %s", port.path);
64+
dexcom.oldConnect(port, true).then(resolve, reject);
65+
return;
66+
}
67+
}
68+
dexcom.oldConnect(serialport, false).then(resolve, reject);
69+
});
70+
});
71+
},
72+
oldConnect: function(serialport, foundActualDevice) {
73+
console.log("getDevices in oldConnect with device: %o", serialport);
5774
return new Promise(function(resolve, reject) {
5875
if (dexcom.connected) {
5976
return reject(new Error("Wait for existing process to finish"));
6077
}
61-
chrome.serial.getDevices(function(ports) {
62-
var connected = function(conn) {
63-
if (conn && "connectionId" in conn) {
64-
dexcom.connection = conn;
65-
dexcom.connected = true;
66-
console.debug("[connecting] successfully connected to port %o", conn);
67-
setTimeout(resolve, 100);
68-
chrome.serial.onReceive.addListener(dexcom.serialOnReceiveListener);
69-
} else {
70-
reject(new Error(
71-
"Couldn't open USB connection. Unplug your Dexcom, plug it back in, and try again."
72-
));
78+
var connected = function(conn) {
79+
if (conn && "connectionId" in conn) {
80+
dexcom.connection = conn;
81+
dexcom.connected = true;
82+
console.debug("[connecting] successfully connected to port %o", conn);
83+
setTimeout(resolve, 100);
84+
chrome.serial.onReceive.addListener(dexcom.serialOnReceiveListener);
85+
} else {
86+
console.error("Couldn't open USB connection to port %o", conn);
87+
reject(new Error(
88+
"Couldn't open USB connection. Unplug your Dexcom, plug it back in, and try again."
89+
));
90+
}
91+
};
92+
var tryPort = function(port) {
93+
console.log("Trying port: " + port);
94+
if (!foundActualDevice &&
95+
(port.path.substr(0,serialport.length).toLowerCase() != serialport.toLowerCase())) {
96+
return;
7397
}
74-
};
75-
ports.forEach(function(port) {
76-
if (port.path.substr(0,serialport.length).toLowerCase() != serialport.toLowerCase()) return;
7798
dexcom.port = port;
7899
console.debug("[connecting] Found dexcom at port %o", port);
79100
chrome.serial.connect(dexcom.port.path, { bitrate: 115200 }, connected);
101+
}
102+
if (foundActualDevice) {
103+
tryPort(serialport);
104+
} else {
105+
chrome.serial.getDevices(function(ports) {
106+
console.log("getDevices returned ports: " + ports);
107+
ports.forEach(tryPort);
108+
if (dexcom.port === null) {
109+
reject(new Error(
110+
"Didn't find a Dexcom receiver plugged in"
111+
));
112+
}
80113
});
81-
if (dexcom.port === null) {
82-
reject(new Error(
83-
"Didn't find a Dexcom receiver plugged in"
84-
));
85-
}
86-
});
114+
}
87115
});
88116
},
89117
serialOnReceiveListener: function(info) {

0 commit comments

Comments
 (0)