mirror of
https://github.com/meshtastic/Meshtastic-Apple.git
synced 2026-04-20 22:13:56 +00:00
Merge pull request #1275 from meshtastic/2.6.7
Additional Connection timing updates
This commit is contained in:
commit
a23557b0ad
2 changed files with 7 additions and 5 deletions
|
|
@ -60,8 +60,8 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
|
||||
private var wantConfigTimer: Timer?
|
||||
private var wantConfigRetryCount = 0
|
||||
private let maxWantConfigRetries = 2
|
||||
private let wantConfigTimeoutInterval: TimeInterval = 5.0
|
||||
private let maxWantConfigRetries = 6
|
||||
private let wantConfigTimeoutInterval: TimeInterval = 6.0
|
||||
|
||||
// MARK: init
|
||||
private override init() {
|
||||
|
|
@ -525,7 +525,6 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
invalidVersion = true
|
||||
return
|
||||
} else {
|
||||
|
||||
// Send Heartbeat before wantConfig
|
||||
var heartbeatToRadio: ToRadio = ToRadio()
|
||||
heartbeatToRadio.payloadVariant = .heartbeat(Heartbeat())
|
||||
|
|
@ -569,13 +568,16 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
|
|||
private func handleWantConfigTimeout() {
|
||||
guard isWaitingForWantConfigResponse else { return }
|
||||
wantConfigRetryCount += 1
|
||||
if wantConfigRetryCount == 1 {
|
||||
allowDisconnect = true
|
||||
}
|
||||
if wantConfigRetryCount < maxWantConfigRetries {
|
||||
Logger.mesh.warning("⏰ Want Config timeout, retrying... (attempt \(self.wantConfigRetryCount + 1)/\(self.maxWantConfigRetries))")
|
||||
sendWantConfig()
|
||||
} else {
|
||||
Logger.mesh.error("🚨 Want Config failed after \(self.maxWantConfigRetries) attempts, forcing disconnect")
|
||||
lastConnectionError = "Bluetooth connection timeout, keep your node closer or reboot your radio if the problem continues.".localized
|
||||
allowDisconnect = true
|
||||
disconnectPeripheral(reconnect: false)
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -282,7 +282,7 @@ struct Connect: View {
|
|||
.controlSize(.large)
|
||||
.padding()
|
||||
}
|
||||
if bleManager.isConnecting {
|
||||
if bleManager.allowDisconnect {
|
||||
Button(role: .destructive, action: {
|
||||
bleManager.cancelPeripheralConnection()
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue