sleep for a second to allow the official app to upload to LibreView

also removed the call to heartbeat after didConnect, that's a bit too early, should not be necessary.
This commit is contained in:
Johan Degraeve 2024-02-23 16:30:04 +01:00
parent f631d54bd8
commit b3dc269c3d
1 changed files with 3 additions and 15 deletions

View File

@ -56,21 +56,6 @@ class Libre3HeartBeatBluetoothTransmitter: BluetoothTransmitter {
// MARK: CBCentralManager overriden functions
override func centralManager(_ central: CBCentralManager, didConnect peripheral: CBPeripheral) {
super.centralManager(central, didConnect: peripheral)
// this is the trigger for calling the heartbeat
if (Date()).timeIntervalSince(lastHeartBeatTimeStamp) > ConstantsHeartBeat.minimumTimeBetweenTwoHeartBeats {
bluetoothTransmitterDelegate?.heartBeat()
lastHeartBeatTimeStamp = Date()
}
}
override func peripheral(_ peripheral: CBPeripheral, didUpdateValueFor characteristic: CBCharacteristic, error: Error?) {
// trace the received value and uuid
@ -81,6 +66,9 @@ class Libre3HeartBeatBluetoothTransmitter: BluetoothTransmitter {
// this is the trigger for calling the heartbeat
if (Date()).timeIntervalSince(lastHeartBeatTimeStamp) > ConstantsHeartBeat.minimumTimeBetweenTwoHeartBeats {
// sleep for a second to allow the official app to upload to LibreView
Thread.sleep(forTimeInterval: 1)
bluetoothTransmitterDelegate?.heartBeat()
lastHeartBeatTimeStamp = Date()