JohanDegraeve / xdripswift

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

Skip calibration need if xdrip on follower mode #401

Closed pvavolas closed 4 months ago

pvavolas commented 1 year ago

I have been switching between Libre 2 and Libre 3 the last few weeks, this an annoying alert that one needs to silence every once in a while. There is no need to trigger the calibration alert when in follower mode

paulplant commented 1 year ago

Interesting... sensor should be nil when in follower mode so it should just return directly from the function anyway.

Unless maybe changing from Master to Follower doesn't nullify the active sensor?

Either way, this would work well and should probably be merged in.

@JohanDegraeve - are you ok to merge into develop?

JohanDegraeve commented 1 year ago

@pvavolas sorry for the late reply. Did you further test this? no issues detected?

@paulplant the cgmtransmitter is set to nil when going from master to follower, see here https://github.com/JohanDegraeve/xdripswift/blob/master/xdrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift#L1147

then probably later, a check is done here https://github.com/JohanDegraeve/xdripswift/blob/master/xdrip/View%20Controllers/Root%20View%20Controller/RootViewController.swift#L1388

'probably' because both checks are done with an observer, probably the first line is triggered before the second line. I think it could be solved by removing line 1388. But it's a bit risky, because here a check is done again https://github.com/JohanDegraeve/xdripswift/blob/master/xdrip/View%20Controllers/Root%20View%20Controller/RootViewController.swift#LL3027C15-L3027C15. If the second line would have been triggered before the first, then cGMTransmitter would not be nil, and in case of Dexcom, it would stop the sensor on the transmitter itself

pvavolas commented 1 year ago

@JohanDegraeve sorry I have long now run out of Libre 2 sensors so no longer have this case. I also noticed the line you refer to, https://github.com/JohanDegraeve/xdripswift/blob/master/xdrip/Managers/BluetoothPeripheral/BluetoothPeripheralManager.swift#L1147 but could not make sense why the sensor was still appearing as "active" triggering the calibration event. I agree fixing the problem upstream is the best solution but I cannot try it atm. I no longer use xdrip (with Libre 3) as in follower mode it consumes too much battery :)