Skip to content

Commit

Permalink
using same empty packet check for Vibe and Ping
Browse files Browse the repository at this point in the history
  • Loading branch information
gniezen committed Jun 13, 2016
1 parent e2bbd5b commit 3bb7290
Showing 1 changed file with 13 additions and 14 deletions.
27 changes: 13 additions & 14 deletions lib/drivers/animasDriver.js
Original file line number Diff line number Diff line change
Expand Up @@ -684,7 +684,7 @@ module.exports = function (config) {
return cb(null,ackResult);
}
} else {
return cb(new Error('Unexpected error'), null);
return cb(new Error('We are having trouble connecting to the pump. Please try again.'), null);
}
});
});
Expand Down Expand Up @@ -1261,20 +1261,25 @@ module.exports = function (config) {
progress(newPercentage);
}

var checkEmpty = function(payload) {
var bytes = struct.extractBytes(payload,4,recordSize-2);
if(bytes.every(function(element){ return element === 0;})) {// empty datum
return true;
} else {
return false;
}
};

var parsePayload = function(result) {
var payload = [].slice.call(result.payload); // copy to regular array

if(modelNumber === 'IR1295') {
// multi-record download
if (!_.isEqual(payload,prevPayload)) { // check that it's not duplicate
prevPayload = payload;
while (payload.length > 4) {
datum = request.parser(payload);
var checkEmpty = struct.extractBytes(payload,4,recordSize-2);
if(checkEmpty.every(function(element){ return element === 0;})) {// empty datum
datum.empty = true;
} else {
datum.empty = false;
}
datum.empty = checkEmpty(payload);
datum.index = index;
console.log('Datum:', datum);
records.push(datum);
Expand Down Expand Up @@ -1302,15 +1307,9 @@ module.exports = function (config) {
}
else {
datum = request.parser(payload);
datum.empty = checkEmpty(payload);
console.log('Datum:', datum);

if(struct.extractInt(payload,4) === 0) {// empty date
datum.empty = true;
}
else{
datum.empty = false;
}

sendAck(true, function (err, result){
if(err) {
return cb(err, null);
Expand Down

0 comments on commit 3bb7290

Please sign in to comment.