mmeowlink icon indicating copy to clipboard operation
mmeowlink copied to clipboard

Add NAK logic to request retransmission from pump based on @ecc1's code

Open wkcwells opened this issue 8 years ago • 3 comments

Code is here: https://github.com/ecc1/medtronic

wkcwells avatar Aug 17 '16 17:08 wkcwells

I have a basic prototype working. Still refining it...

wkcwells avatar Aug 17 '16 17:08 wkcwells

Heya Keving. I'm just discovering the wonders of the golang code that Eric worked on. I wasn't entirely sure what this issue relates to, though? Would you mind adding some detail/explanation? Thanks!

oskarpearson avatar Sep 15 '16 22:09 oskarpearson

When requesting a history page from a MM pump, the protocol returns 16 records to make up the whole page of data. The client sends the request, gets the first record, then has to send an ACK for each subsequent record.

The records have sequence numbers 1..16. Previously, if you were expecting #7 but instead got #8, you would realize that you'd lost #7, throw up your hands, and return failure for the whole operation.

I discovered that the protocol also accepts a NAK instead of an ACK, which will cause retransmission of the current record. Unfortunately, the ACKs and NAKs don't have sequence numbers so the logic is a little tricky -- you can't wait until you see an unexpected sequence number because then it's too late. You have to send the NAK when you timeout expecting a response.

Anyway, the net result is that history page fetches in noisy or marginal comms environments are much more likely to suceed.

ecc1 avatar Sep 16 '16 00:09 ecc1