JohanDegraeve / xdripswift

xdrip for iOS, written in Swift
GNU General Public License v3.0
339 stars 337 forks source link

A test “companion” mode for Libre 2 / LibreLink #362

Closed gui-dos closed 2 years ago

gui-dos commented 2 years ago

If you just activate the notifications on the Libre 2 read characteristic without sending the unlock payload and then launch LibreLink, you can receive the data regularly while keeping both apps running side-by-side, even after closing LibreLink.

https://github.com/JohanDegraeve/xdripswift/blob/f487db5712eb37838de07d65eaaff119ea98cda3/xdrip/BluetoothTransmitter/CGM/Libre/Libre2/CGMLibre2Transmitter.swift#L242

This is technically possible on iOS with any app since in CoreBluetooth the connections are reference-counted and a device has no clue that the same characteristics’ values will be notified to all the multiple apps that subscribed to them.

It could be a way to test the app without activating BLE on your own since LibreLink can keep on reconnecting successfully to the sensor and turning off the red exclamation mark regarding the alarms unavailability in a couple of minutes.

I implemented it very easily in the “Test” mode of https://github.com/gui-dos/DiaBLE so I think that porting it will be quite doaBLE :-)

JohanDegraeve commented 2 years ago

test mode means LibreLink and DiaBLE run in parallel? The patchInfo is needed to decrypt the data, that patchInfo is received via NFC (and changes with every NFC scan). So it's the app that did the NFC scan that can do something with the data. So what's the purpose of the 'sniffing' ?

JohanDegraeve commented 2 years ago

Ok. Some users might be interested to have a follow mode (similar to what is available for Dexcom users : 'Follow Dexcom App', in which case the official Dexcom app is installed and xDrip4iOS just receives the readings.

But it looks a bit more complex for Libre, i mean for the user. Because an initial scan looks needed (not only useful) to get the Libre Derived algorithm parameters : https://github.com/JohanDegraeve/xdripswift/blob/f487db5712eb37838de07d65eaaff119ea98cda3/xdrip/BluetoothTransmitter/CGM/Libre/Libre2/CGMLibre2Transmitter.swift#L383

right?

Does that mean you're able to read Libre 3 readings using the sniffing method?

JohanDegraeve commented 2 years ago

looks impressive

JohanDegraeve commented 2 years ago

It works nicely actually (at least with two instances of xDrip4iOS, which could be interesting eg to compare calibration vs Libre algo)

I'll add an option in the developer settings to suppress writing the unLockPayLoad