Skip to content

Commit

Permalink
reads records from OneTouch meter via extension and uploads successfu…
Browse files Browse the repository at this point in the history
…lly!
  • Loading branch information
gniezen committed Mar 4, 2024
1 parent 7ca42b6 commit 75df78e
Showing 1 changed file with 9 additions and 6 deletions.
15 changes: 9 additions & 6 deletions lib/drivers/onetouch/oneTouchVerio.js
Original file line number Diff line number Diff line change
Expand Up @@ -438,9 +438,13 @@ class NativeMessaging {
}
}

closeDevice() {
closeDevice(callback) {
chrome.runtime.sendMessage(this.extensionId, { command: 'closeDevice' }, (response) => {
console.log("Closed:". response);
if (callback) {
return callback();
}
return null;
});
}

Expand All @@ -465,10 +469,7 @@ class NativeMessaging {
const seekOffset = lbaNumber * BLOCKDEVICE_BLOCKSIZE;

chrome.runtime.sendMessage(this.extensionId, { command: 'retrieveData', request: Array.from(requestData), seekOffset }, (response) => {
console.log('Response:', response);

if (response.msgType === 'data') {
console.log('Details:', String.fromCharCode(null, response.details));
callback(null, Buffer.from(response.details));
} else {
callback(new Error(response.details));
Expand Down Expand Up @@ -638,7 +639,7 @@ class OneTouchVerio {
if (err) {
return callback(err);
}
const recordCount = commandData.readUInt16LE();
const recordCount = commandData.readUInt16LE(0);
debug('retrieveRecordCount:', recordCount);
const data = {};
data.recordCount = recordCount;
Expand Down Expand Up @@ -733,6 +734,7 @@ export default function (config) {
// With no date & time settings changes available,
// timezone is applied across-the-board
cfg.tzoUtil = new TZOUtil(cfg.timezone, new Date().toISOString(), []);
cfg.deviceInfo = {};
assign(cfg.deviceInfo, {
tags: ['bgm'],
manufacturers: ['LifeScan'],
Expand Down Expand Up @@ -788,6 +790,7 @@ export default function (config) {
cb(err2, null);
return;
}

assign(cfg.deviceInfo, { model: deviceModel.deviceModel });
data.deviceModel = cfg.deviceInfo.model; // for metrics
progress(100);
Expand Down Expand Up @@ -872,7 +875,7 @@ export default function (config) {
deviceManufacturers: cfg.deviceInfo.manufacturers,
deviceModel: cfg.deviceInfo.model,
deviceSerialNumber: cfg.deviceInfo.serialNumber,
deviceTime: data.deviceInfo.deviceTime,
deviceTime: cfg.deviceInfo.deviceTime,
deviceId: cfg.deviceInfo.deviceId,
start: sundial.utcDateString(),
timeProcessing: cfg.tzoUtil.type,
Expand Down

0 comments on commit 75df78e

Please sign in to comment.