Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

new dev area post 0.0.12 release #26

Open
wants to merge 16 commits into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -178,6 +178,9 @@ Other available values for `CONNECT_LINK_UP_REGION`:
For folks connected to many patients, you can provide the patient ID by setting
the `CONNECT_LINK_UP_PATIENT_ID` variable.

Optionally, you can override the default 5-minute refresh interval by providing
`CONNECT_LINK_UP_INTERVAL` as an integer representing minutes.

### Minimed Carelink

To synchronize from Medtronic Minimed Carelink, set the following
Expand Down
14 changes: 13 additions & 1 deletion lib/sources/glooko/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@

var qs = require('qs');
var url = require('url');
var uid = require('uid');

var helper = require('./convert');

Expand Down Expand Up @@ -51,7 +52,18 @@ function login_payload (opts) {
"password": opts.glookoPassword
},
"deviceInformation": {
"deviceModel": "iPhone"
"applicationType": "logbook",
"os": "android",
"osVersion": "33",
"device": "Google Pixel 4a",
"deviceManufacturer": "Google",
"deviceModel": "Pixel 4a",
"serialNumber": "ab43bfjdj3423421fb",
"clinicalResearch": false,
"deviceId": "716c34bac673f4b9",
"applicationVersion": "6.1.3",
"buildNumber": "0",
"gitHash": "g4fbed2011b"
}
};
return body;
Expand Down
12 changes: 7 additions & 5 deletions lib/sources/librelinkup.js
Original file line number Diff line number Diff line change
Expand Up @@ -121,7 +121,7 @@ function linkUpSource (opts, axios) {
var { status, data, ticket } = payload;
var batch = data;
// TODO: TRANSFORM
var last_updated = last_known.entries;
var last_updated = (last_known && last_known.entries) ? last_known.entries : null;
function is_newer (elem) {
if (!last_known) { return true; };
return last_known.entries < new Date(elem.dateString);
Expand All @@ -141,7 +141,8 @@ function linkUpSource (opts, axios) {
};
}

var entries = batch.graphData.map(to_ns_sgv).filter(is_newer);
// add current value to the list to avoid 20min delay, remove filtering since NS automatically removes duplicates
var entries = batch.graphData.concat([batch.connection.glucoseItem]).map(to_ns_sgv);
var treatments = [ ];
var devicestatus = [ ];
var profiles = [ ];
Expand All @@ -155,12 +156,12 @@ function linkUpSource (opts, axios) {
}
// var last_glucose_at = new Date(last_known.sgvs.mills);
var last_glucose_at = last_known.entries;
var missing = ((new Date( )).getTime( ) - last_glucose_at.getTime( )) / (1000 * 60 * 5)
var missing = ((new Date( )).getTime( ) - last_glucose_at.getTime( )) / (1000 * 60 * opts.linkUpInterval)
if (missing > 1 && missing < 3) {
console.log("READJUSTING SHOULD MAKE A DIFFERENCE MISSING", missing);

}
var next_due = last_glucose_at.getTime( ) + (Math.ceil(missing) * 1000 * 60 * 5);
var next_due = last_glucose_at.getTime( ) + (Math.ceil(missing) * 1000 * 60 * opts.linkUpInterval);
var buffer_lag = 18000; // 18 second buffer
var jitter = Math.floor(Math.random( ) * 1000 * 18); // 18 second random
var align_to = next_due + buffer_lag + jitter;
Expand Down Expand Up @@ -200,7 +201,7 @@ function linkUpSource (opts, axios) {
maxRetries: 2
},
// expect new data 5 minutes after last success
expected_data_interval_ms: 5 * 60 * 1000,
expected_data_interval_ms: opts.linkUpInterval * 60 * 1000,
backoff: {
// wait 2.5 minutes * 2^attempt
interval_ms: 2.5 * 60 * 1000
Expand All @@ -220,6 +221,7 @@ linkUpSource.validate = function validate_inputs (input) {
linkUpUsername: input.linkUpUsername,
linkUpPassword: input.linkUpPassword,
linkUpPatientId: input.linkUpPatientId,
linkUpInterval: input.linkUpInterval || 5,
linkUpVersion: input.linkUpVersion || Defaults.Version,
linkUpProduct: input.linkUpProduct || Defaults.Product,
baseURL
Expand Down
Loading