From c8dc97acb60188a61149ed5cd273c37a87033bf4 Mon Sep 17 00:00:00 2001 From: Casey Date: Thu, 4 Aug 2022 23:03:46 -0600 Subject: [PATCH] invalidate existing timer before creating a new one --- Meshtastic/Helpers/BLEManager.swift | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 636b0f35..2fd21994 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -168,6 +168,9 @@ class BLEManager: NSObject, ObservableObject, CBCentralManagerDelegate, CBPeriph 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")"]