Skip to content

Commit

Permalink
Implement Link Up Interval
Browse files Browse the repository at this point in the history
  • Loading branch information
ady624 committed Jan 24, 2024
1 parent 1e63c53 commit dc5b251
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 4 deletions.
7 changes: 4 additions & 3 deletions lib/sources/librelinkup.js
Original file line number Diff line number Diff line change
Expand Up @@ -155,12 +155,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 +200,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 +220,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
2 changes: 1 addition & 1 deletion machines.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ on a regular, periodic interval. For CGM devices, this is nominally five
minutes, although some providers are known to update on an hourly or daily cadence.
The configured expected data interval helps establish the basis of this
cadence. Each vendor may describe one or more cycle machines consuming
sesssions from that vendor. The cycle machine is owned by the polling machine
sessions from that vendor. The cycle machine is owned by the polling machine
and forwards `SESSION_RESOLVED`, `SESSION_REQUIRED`, and `SESSION_ERROR`
between polling/bus machine and the fetch machine. Consumers on a cycle
machine will loop through
Expand Down

0 comments on commit dc5b251

Please sign in to comment.