ecc1 / medtronic

Go package for communicating with Medtronic insulin pumps via SPI-attached radio modules
MIT License
38 stars 29 forks source link

mdt sensitivities fails to decode time correctly. #12

Closed tzachi-dar closed 5 years ago

tzachi-dar commented 5 years ago

Looking at the code here: https://github.com/ecc1/medtronic/blob/835e00374362905fc20f17ddeece0f924168b37f/sensitivities.go#L21

I see start := halfHoursToTimeOfDay(n & 0x1F) Since there are 48 half hours in a day, while n& 0x1f is limited to 31, we can not decode the entire day.

More, In my case, I have time = 21:00 which is 42 in half hours 42 & 0x 1f => A So, A = 10 half hours is 05:00. And indeed I'm getting the insulin sensitivities to start at 05:00 and not at 21:00.

ecc1 commented 5 years ago

Thanks for finding this. Changed the mask to 0x3F to use 6 bits for the time slot.