Merge pull request #140 from meshtastic/cancel-timer

invalidate existing timer before creating a new one
This commit is contained in:
Garth Vander Houwen 2022-08-06 19:52:13 -07:00 committed by GitHub
commit a03f50da51
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -170,6 +170,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph
self.connectedVersion = "0.0.0"
self.centralManager?.connect(peripheral)
// Invalidate any existing timer
self.timeoutTimer?.invalidate()
// Use a timer to keep track of connecting peripherals, context to pass the radio name with the timer and the RunLoop to prevent
// the timer from running on the main UI thread
let context = ["name": "@\(peripheral.name ?? "Unknown")"]