creepymonster / GlucoseDirect

App programmed in Swift/SwiftUI for using Libre blood glucose sensors.
MIT License
361 stars 116 forks source link

Ascertain age > 0 before setting state to .starting #486

Closed gui-dos closed 1 year ago

gui-dos commented 1 year ago

[EDITED]

creepymonster commented 1 year ago

Hello gui-dos,

thank you for your message - I'm always happy to hear from you.

I suspect the problem is more difficult to solve. Right now I can't get the age of the sensor from the NFC scan of the Libre 3. I don't get the real age of the sensor until I retrieve the data from LibreLinkUp.

Therefore, I set the age of the sensor to 0 during the NFC scan, which means that the sensor is set to "Starting" until the first data retrieval. I do this because I only allow connections to the sensor when the status is "Starting" or "Ready".

https://github.com/creepymonster/GlucoseDirect/blob/31e1e902a5e66fbf6d0f4b8eb03f88624f322572/Library/Content/Sensor.swift#L218

If I would not do this, the sensor might not be connected otherwise, and then the real age of LibreLinkUp could not be retrieved.

It would be better to determine the age from the NFC scan. Maybe you have a tip.

Many greetings Reimar

OddSquirrel commented 1 year ago

Thanks for the explanation, that "starting" message from an already started sensor always puzzled me. 😋