JohanDegraeve / xdripswift

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

Only store CGM address to user defaults when app is set as "Active CGM", and fix typo in "CGM" #398

Open bjornoleh opened 1 year ago

bjornoleh commented 1 year ago

The intention with this commit is to avoid having the app set as "inactive CGM" (setActiveCGM = off) to store the wrong CGM transmitter address to shared user defaults, which will break the Heartbeat mechanism for FreeAPS X. This is in the context of using two instances of xdrip4iOS when running overlapping sensor sessions with Anubis G6.

I am not sure if this will work as intended, but at least it builds.

JohanDegraeve commented 1 year ago

there is already an option "Suppress Loop Share" in the developer settings, that suppress also setting the cgm transmitter address see https://github.com/JohanDegraeve/xdripswift/blob/ab1b5b9b72ab35aa00389e91c1196bc540fd9146/xdrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift#L54

bjornoleh commented 1 year ago

there is already an option "Suppress Loop Share" in the developer settings, that suppress also setting the cgm transmitter address see

https://github.com/JohanDegraeve/xdripswift/blob/ab1b5b9b72ab35aa00389e91c1196bc540fd9146/xdrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift#L54

Oh, I didn’t realise, thanks! Then this should probably be tied to the “Set as active CGM” setting then. Suppress loop share = off when active CGM is on, suppress loop share = on when active CGM is off?

JohanDegraeve commented 1 year ago

there is already an option "Suppress Loop Share" in the developer settings, that suppress also setting the cgm transmitter address see https://github.com/JohanDegraeve/xdripswift/blob/ab1b5b9b72ab35aa00389e91c1196bc540fd9146/xdrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift#L54

Oh, I didn’t realise, thanks! Then this should probably be tied to the “Set as active CGM” setting then. Suppress loop share = off when active CGM is on, suppress loop share = on when active CGM is off?

yes it would be better to set suppressLoopShare accordingly

bjornoleh commented 1 year ago

@JohanDegraeve , I think I have set suppressLooppShare correctly now, please see https://github.com/bjornoleh/xdripswift/commit/951a454101ba7ef30184d1b075f2c7edf79ba67f

bjornoleh commented 1 year ago

This change removes the risk of accidentally breaking the heartbeat mechanism by opening the wrong app. But it is still required to force close and reopen the app to guarantee that the transmitter address is written to shared user defaults ( the last opened app will write its transmitter address upon start). Would it be possible to force the current app to write the transmitter address when we switch on SetActiveCGM, without a restar of the app?