Skip to content

Commit

Permalink
Merge pull request tidepool-org#609 from tidepool-org/pazaan/medtroni…
Browse files Browse the repository at this point in the history
…c600-comms-errors

[WIP] Comms error handling bug fix
  • Loading branch information
pazaan authored May 3, 2018
2 parents 081caca + d86c191 commit 0f97866
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 11 deletions.
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.2.5-600series-qa.20",
"version": "2.2.5-600series-qa.21",
"description": "Tidepool Project Universal Uploader",
"main": "./main.js",
"author": {
Expand Down
21 changes: 12 additions & 9 deletions lib/drivers/medtronic600/medtronic600Driver.js
Original file line number Diff line number Diff line change
Expand Up @@ -761,6 +761,9 @@ class MultipacketSession {

addSegment(segment) {
debug(`*** Got a Multipacket Segment: ${segment.packetNumber + 1} of ${this.packetsToFetch}, count: ${this.segmentsFilled + 1}`);
if (this.packetsToFetch === this.segmentsFilled) {
throw new InvalidStateError('Segments already filled. Should not be getting duplicates.');
}

if (segment.segmentPayload != null) {
// multiByteSegments don't always come back in a consecutive order.
Expand Down Expand Up @@ -988,6 +991,14 @@ class TransmitPacketRequest extends NGPRequest {
this.ngpRetries += 1;
}
debug(`Multipacket retry: ${this.ngpRetries}`);
if (err instanceof TimeoutError) {
debug('Got timeout waiting for message.');
} else if (err instanceof InvalidMessageError) {
debug('Invalid Message');
} else {
debug('Unknown error occurred while reading Multipacket message.');
throw new InvalidStateError('Software Error. Contact Tidepool support.');
}

if (this.ngpRetries > NGPRequest.MAX_RETRIES) {
throw new RetryError('Exceeded retries for TransmitPacketRequest');
Expand All @@ -998,6 +1009,7 @@ class TransmitPacketRequest extends NGPRequest {
if (nextMissingSegment !== undefined) {
fetchMoreData = true;
debug('Requesting missing packets');
this.ngpRetries = 0;
await Timer.wait(TransmitPacketRequest.MULTIPACKET_ACK_DELAY_MS);
await new MultipacketResendPacketsCommand(
this.pumpSession,
Expand All @@ -1009,15 +1021,6 @@ class TransmitPacketRequest extends NGPRequest {
}
}
}

if (err instanceof TimeoutError) {
debug(`Got timeout waiting for message. On retry ${this.ngpRetries}`);
} else if (err instanceof InvalidMessageError) {
debug('Invalid Message');
} else {
debug('Unknown error occurred while reading Multipacket message.');
debug(err);
}
}
}
/* eslint-enable no-use-before-define */
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.2.5-600series-qa.20",
"version": "2.2.5-600series-qa.21",
"description": "Tidepool Project Universal Uploader",
"private": true,
"main": "main.js",
Expand Down

0 comments on commit 0f97866

Please sign in to comment.