From a4165017790e47e706f29d0827b2e52c3130cffd Mon Sep 17 00:00:00 2001 From: Andy Low <42089621+AndyLow91@users.noreply.github.com> Date: Mon, 7 Aug 2023 17:19:58 +0100 Subject: [PATCH 1/6] Update librelinkup.js fixed path for trace-axios dependency --- lib/sources/librelinkup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sources/librelinkup.js b/lib/sources/librelinkup.js index a3b25e5..dae2c45 100644 --- a/lib/sources/librelinkup.js +++ b/lib/sources/librelinkup.js @@ -161,7 +161,7 @@ function linkUpSource (opts, axios) { } }; function tracker_for ( ) { - var AxiosTracer = require('../../trace-axios'); + var AxiosTracer = require('../trace-axios'); var tracker = AxiosTracer(http); return tracker; } From a152e4a9876f34d4ffd5d60a1273e41f32a6e18f Mon Sep 17 00:00:00 2001 From: Andy Low <42089621+AndyLow91@users.noreply.github.com> Date: Mon, 7 Aug 2023 18:49:51 +0100 Subject: [PATCH 2/6] Update librelinkup.js Bug found - "var connections = resp.data.data;" --- lib/sources/librelinkup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sources/librelinkup.js b/lib/sources/librelinkup.js index dae2c45..f613d8a 100644 --- a/lib/sources/librelinkup.js +++ b/lib/sources/librelinkup.js @@ -79,7 +79,7 @@ function linkUpSource (opts, axios) { }; return http.get(Defaults.Connections, { headers }).then((resp) => { console.log("CONNECTIONS RESPONSE FROM LIBRELINKUP", resp.status, resp.headers, resp.data); - var connections = resp.data.data; + var connections = resp.data; if (connections.length == 0) { var err = new Error("NO CONNECTION WITH LIBRE LINKUP AVAILABLE"); From a99dce44ffd09a3c7a3d2321cd93f4a512b664aa Mon Sep 17 00:00:00 2001 From: Andy Low <42089621+AndyLow91@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:03:40 +0100 Subject: [PATCH 3/6] Update librelinkup.js This was not a bug afterall, reverting. --- lib/sources/librelinkup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sources/librelinkup.js b/lib/sources/librelinkup.js index f613d8a..dae2c45 100644 --- a/lib/sources/librelinkup.js +++ b/lib/sources/librelinkup.js @@ -79,7 +79,7 @@ function linkUpSource (opts, axios) { }; return http.get(Defaults.Connections, { headers }).then((resp) => { console.log("CONNECTIONS RESPONSE FROM LIBRELINKUP", resp.status, resp.headers, resp.data); - var connections = resp.data; + var connections = resp.data.data; if (connections.length == 0) { var err = new Error("NO CONNECTION WITH LIBRE LINKUP AVAILABLE"); From 75fd3f9a5e278e449f189b94c0793622bac3bdfd Mon Sep 17 00:00:00 2001 From: Andy Low <42089621+AndyLow91@users.noreply.github.com> Date: Mon, 7 Aug 2023 19:35:43 +0100 Subject: [PATCH 4/6] Update librelinkup.js Typo found in "opts.linkUpPatientId;" --- lib/sources/librelinkup.js | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lib/sources/librelinkup.js b/lib/sources/librelinkup.js index dae2c45..fce5936 100644 --- a/lib/sources/librelinkup.js +++ b/lib/sources/librelinkup.js @@ -71,7 +71,7 @@ function linkUpSource (opts, axios) { }, sessionFromAuth (auth) { function isPatient (elem) { - return elem.patientId == opts.patientId; + return elem.patientId == opts.linkUpPatientId; } var token = auth.data.authTicket.token; var headers = { From f1ed8001cec25012dce45282ce81699892ba7b43 Mon Sep 17 00:00:00 2001 From: Andy Low <42089621+AndyLow91@users.noreply.github.com> Date: Wed, 9 Aug 2023 22:24:00 +0100 Subject: [PATCH 5/6] Update pump clock to correct timezone --- lib/sources/minimedcarelink/index.js | 35 ++++++++++++++++++++-------- 1 file changed, 25 insertions(+), 10 deletions(-) diff --git a/lib/sources/minimedcarelink/index.js b/lib/sources/minimedcarelink/index.js index b9bf822..cce89c1 100644 --- a/lib/sources/minimedcarelink/index.js +++ b/lib/sources/minimedcarelink/index.js @@ -552,28 +552,38 @@ function carelinkSource (opts, axios) { return elem; } - function reassign_zone ( ) { + function reassign_zone(item) { if (lastConduitDateTime) { - var zoneOffsetMatch = lastConduitDateTime.match(/[+-]\d{2}:\d{2}$/); - var zoneOffset = zoneOffsetMatch ? zoneOffsetMatch[0] : '00:00'; - return adjust_conduit_timezone.bind(null, zoneOffset); + var zoneOffsetMatch = lastConduitDateTime.match(/[+-]\d{2}:\d{2}$/); + var zoneOffset = zoneOffsetMatch ? zoneOffsetMatch[0] : '00:00'; + return adjust_conduit_timezone(zoneOffset, item); } - return id; + return id(item); } + + function id(x) { return x; } - function id (x) { return x; } - function adjust_conduit_timezone (zoneOffset, item) { - item.datetime = item.datetime.replace('Z', `${zoneOffset}`); + function adjust_conduit_timezone(zoneOffset, item) { + // Handle item.datetime + if (item.datetime && item.datetime.endsWith('Z')) { + item.datetime = item.datetime.replace('Z', `${zoneOffset}`); + } + + // Handle item.pump.clock + if (item.pump && item.pump.clock) { + // Replace the current zone offset at the end of the string with the new one + item.pump.clock = item.pump.clock.replace(/[+-]\d{2}:\d{2}$/, `${zoneOffset}`); + } + return item; } var entries = data.sgs .filter(has_datetime) - .map(reassign_zone( )) + .map(reassign_zone) .map(sgs_to_sgv) .filter(is_missing) .map(assign_device); - // var devicestatus = [{ }]; // only the last item has its trend described. var lastItem = entries.pop( ) @@ -587,6 +597,11 @@ function carelinkSource (opts, axios) { var deviceStatus = deviceStatusEntry(data, deviceName); var devicestatus = [ deviceStatus ]; + if (lastConduitDateTime) { + var zoneOffsetMatch = lastConduitDateTime.match(/[+-]\d{2}:\d{2}$/); + var zoneOffset = zoneOffsetMatch ? zoneOffsetMatch[0] : '00:00'; + deviceStatus = adjust_conduit_timezone(zoneOffset, deviceStatus); + } var treatments = [ ]; console.log("INCOMING TALLY", data.sgs.length, 'reduced', entries.length); console.log("INCOMING DEVICESTATUS", deviceStatus); From b4f3f01ecbe9d49800ea329eea46ae4dd53b5c5b Mon Sep 17 00:00:00 2001 From: Andy Low <42089621+AndyLow91@users.noreply.github.com> Date: Thu, 17 Aug 2023 19:32:22 +0100 Subject: [PATCH 6/6] Update User-Agent string in http headers --- lib/sources/minimedcarelink/index.js | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/lib/sources/minimedcarelink/index.js b/lib/sources/minimedcarelink/index.js index cce89c1..0723bae 100644 --- a/lib/sources/minimedcarelink/index.js +++ b/lib/sources/minimedcarelink/index.js @@ -5,7 +5,8 @@ var tough = require('tough-cookie'); var ACS = require('axios-cookiejar-support'); var software = require('../../../package.json'); -var user_agent_string = [software.name, `${software.name}@${software.version}`, 'M2M@V6', software.homepage].join(', '); +//var user_agent_string = [software.name, `${software.name}@${software.version}`, 'M2M@V6', software.homepage].join(', '); +var user_agent_string = "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.85 Safari/537.36 Edg/90.0.818.46"; // https://github.com/NightscoutFoundation/xDrip/blob/990df119a8404cff56cb68b92a7e0bb640da95ef/app/src/main/java/com/eveningoutpost/dexdrip/cgm/carelinkfollow/client/CareLinkClient.java#L559 // https://github.com/nightscout/minimed-connect-to-nightscout/blob/master/carelink.js