Skip to content

Commit

Permalink
Merge branch 'master' into accu-chek-threshold
Browse files Browse the repository at this point in the history
  • Loading branch information
gniezen authored Jun 27, 2024
2 parents 333a946 + 624f644 commit 95fb49e
Show file tree
Hide file tree
Showing 8 changed files with 40 additions and 11 deletions.
3 changes: 2 additions & 1 deletion .eslintrc
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,8 @@
"browser": true,
// in CommonJS
"node": true,
"es6": true
"es6": true,
"es2020": true // e.g. BigInt
},
"globals": {
"jest": true,
Expand Down
15 changes: 15 additions & 0 deletions app/actions/async.js
Original file line number Diff line number Diff line change
Expand Up @@ -333,6 +333,11 @@ export function doDeviceUpload(driverId, opts = {}, utc) {
version: version
};

if (targetDevice.powerOnlyWarning) {
displayErr = new Error(ErrorMessages.E_USB_CABLE);
deviceDetectErrProps.code = 'E_USB_CABLE';
}

if (_.get(targetDevice, 'source.driverId', null) === 'Dexcom') {
displayErr = new Error(ErrorMessages.E_DEXCOM_CONNECTION);
deviceDetectErrProps.code = 'E_DEXCOM_CONNECTION';
Expand Down Expand Up @@ -387,6 +392,11 @@ export function doDeviceUpload(driverId, opts = {}, utc) {
} else if (_.get(targetDevice, 'source.driverId', null) === 'BluetoothLE') {
errorMessage = 'E_BLUETOOTH_PAIR';
}

if (targetDevice.powerOnlyWarning) {
errorMessage = 'E_USB_CABLE';
}

device.upload(
driverId,
opts,
Expand Down Expand Up @@ -460,6 +470,11 @@ export function doUpload(deviceKey, opts, utc) {
code: 'E_HID_CONNECTION',
};

if (targetDevice.powerOnlyWarning) {
hidErr = new Error(ErrorMessages.E_USB_CABLE);
errProps.code = 'E_USB_CABLE';
}

if (process.env.NODE_ENV !== 'test') {
errProps = await actionUtils.sendToRollbar(hidErr, errProps);
}
Expand Down
2 changes: 1 addition & 1 deletion app/actions/sync.js
Original file line number Diff line number Diff line change
Expand Up @@ -410,7 +410,7 @@ export function uploadProgress(step, percentage, isFirstUpload) {

export function uploadSuccess(userId, device, upload, data, utc) {
utc = actionUtils.getUtc(utc);
const numRecs = _.get(data, 'post_records.length', undefined);
const numRecs = data?.post_records?.length || data?.postRecords?.length;
const properties = {
type: _.get(device, 'source.type', undefined),
deviceModel: _.get(data, 'deviceModel', undefined),
Expand Down
2 changes: 1 addition & 1 deletion app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "tidepool-uploader",
"productName": "tidepool-uploader",
"version": "2.57.0-accu-chek-threshold.1",
"version": "2.57.0-km-processed.1",
"description": "Tidepool Project Universal Uploader",
"main": "./main.prod.js",
"author": {
Expand Down
9 changes: 6 additions & 3 deletions app/reducers/devices.js
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,8 @@ const devices = {
key: 'contourplus',
name: 'Ascensia Contour Plus One/Blue',
source: {type: 'device', driverId: 'ContourPlus'},
enabled: {mac: true, win: true, linux: true}
enabled: {mac: true, win: true, linux: true},
powerOnlyWarning: true,
},
caresens: {
instructions: i18n.t('Plug in meter with cable and make sure the meter is switched on'),
Expand Down Expand Up @@ -96,7 +97,8 @@ const devices = {
name: 'Equil Insulin Patch/Micro Pump',
key: 'weitai',
source: {type: 'device', driverId: 'Weitai'},
enabled: {mac: true, win: true, linux: true}
enabled: {mac: true, win: true, linux: true},
powerOnlyWarning: true
},
foracareble: {
instructions: i18n.t('Hold Bluetooth switch on meter until Bluetooth indicator starts to flash'),
Expand Down Expand Up @@ -128,7 +130,8 @@ const devices = {
name: 'GLUCOCARD Shine Connex & Shine Express',
key: 'glucocardshinehid',
source: {type: 'device', driverId: 'GlucocardShineHID'},
enabled: {mac: true, win: true, linux: true}
enabled: {mac: true, win: true, linux: true},
powerOnlyWarning: true
},
glucocardvital: {
instructions: i18n.t('Make sure the meter is switched off and plug in cable'),
Expand Down
4 changes: 4 additions & 0 deletions lib/drivers/onetouch/oneTouchVerio.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,10 @@ class USBScsiDevice {
}

openDevice(deviceInfo, callback) {
if (!deviceInfo.usbDevice) {
return callback(new Error(`Could not find device "${deviceInfo.driverId}".`));
}

this.device = findByIds(deviceInfo.usbDevice.vendorId, deviceInfo.usbDevice.productId);
if (!this.device) {
return callback(new Error(`Failed to open connection to ${deviceInfo.driverId}`));
Expand Down
14 changes: 10 additions & 4 deletions lib/drivers/roche/accuChekUSB.js
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,11 @@ class AccuChekUSB {
const lastInvokeId = incoming.data.getUint16(6);
debug('Received set time response:', common.bytes2hex(new Uint8Array(incoming.data.buffer), true));

return cb(lastInvokeId);
if (incoming.data.getUint16(8) !== DATA_ADPU.RESPONSE_CONFIRMED_ACTION) {
return cb(new Error('Could not set time on device'));
}

return cb(null, lastInvokeId);
}

async getData(invokeId, pmStoreHandle, cb) {
Expand Down Expand Up @@ -590,11 +594,13 @@ module.exports = (config) => {
if (timeErr) {
if (timeErr === 'updateTime') {
cfg.deviceInfo.annotations = 'wrong-device-time';
const newTime = sundial.formatInTimezone(serverTime, cfg.timezone, 'YYYYMMDDHHmm');
driver.setTime(data.lastInvokeId, data.pmStoreHandle, newTime, (invokeId) => {
const timeString = sundial.formatInTimezone(serverTime, cfg.timezone, 'YYYYMMDDHHmmss');
const newTime = BigInt(`0x${timeString}00`);

driver.setTime(data.lastInvokeId, data.pmStoreHandle, newTime, (err, invokeId) => {
_.assign(data, result);
data.lastInvokeId = invokeId;
return cb(null, data);
return cb(err, data);
});
} else {
cb(timeErr, null);
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "tidepool-uploader",
"version": "2.57.0-accu-chek-threshold.1",
"version": "2.57.0-km-processed.1",
"description": "Tidepool Project Universal Uploader",
"private": true,
"main": "main.prod.js",
Expand Down

0 comments on commit 95fb49e

Please sign in to comment.