From 04fef0cba97f720712049b281af3ce36f836e216 Mon Sep 17 00:00:00 2001 From: Garth Vander Houwen Date: Tue, 30 Apr 2024 12:26:57 -0700 Subject: [PATCH] Get out of disconnect loop --- Meshtastic/Helpers/BLEManager.swift | 3 +++ Meshtastic/Views/Bluetooth/Connect.swift | 12 ++++++++++++ 2 files changed, 15 insertions(+) diff --git a/Meshtastic/Helpers/BLEManager.swift b/Meshtastic/Helpers/BLEManager.swift index 084fe083..394d6d61 100644 --- a/Meshtastic/Helpers/BLEManager.swift +++ b/Meshtastic/Helpers/BLEManager.swift @@ -151,12 +151,15 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate isConnecting = false isConnected = false isSubscribed = false + self.connectedPeripheral = nil invalidVersion = false connectedVersion = "0.0.0" connectedPeripheral = nil if timeoutTimer != nil { timeoutTimer!.invalidate() } + automaticallyReconnect = false + stopScanning() startScanning() } diff --git a/Meshtastic/Views/Bluetooth/Connect.swift b/Meshtastic/Views/Bluetooth/Connect.swift index da0b2a9e..8fa4d162 100644 --- a/Meshtastic/Views/Bluetooth/Connect.swift +++ b/Meshtastic/Views/Bluetooth/Connect.swift @@ -258,6 +258,18 @@ struct Connect: View { .controlSize(.large) .padding() } + if bleManager.isConnecting { + Button(role: .destructive, action: { + bleManager.cancelPeripheralConnection() + + }) { + Label("disconnect", systemImage: "antenna.radiowaves.left.and.right.slash") + } + .buttonStyle(.bordered) + .buttonBorderShape(.capsule) + .controlSize(.large) + .padding() + } #endif Spacer() }