Get out of disconnect loop

This commit is contained in:
Garth Vander Houwen 2024-04-30 12:26:57 -07:00
parent 60831f6e75
commit 04fef0cba9
2 changed files with 15 additions and 0 deletions

View file

@ -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()
}

View file

@ -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()
}