Merge pull request #1274 from meshtastic/2.6.7

Connection Fixes
This commit is contained in:
Garth Vander Houwen 2025-06-17 20:45:25 -07:00 committed by GitHub
commit 2a0bb73fb6
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -525,11 +525,19 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
invalidVersion = true
return
} else {
// Send Heartbeat before wantConfig
var heartbeatToRadio: ToRadio = ToRadio()
heartbeatToRadio.payloadVariant = .heartbeat(Heartbeat())
guard let heartbeatBinaryData: Data = try? heartbeatToRadio.serializedData() else {
Logger.mesh.error("Failed to serialize Heartbeat ToRadio message")
return
}
connectedPeripheral!.peripheral.writeValue(heartbeatBinaryData, for: TORADIO_characteristic, type: .withResponse)
let nodeName = connectedPeripheral?.peripheral.name ?? "Unknown".localized
let logString = String.localizedStringWithFormat("Issuing Want Config to %@".localized, nodeName)
Logger.mesh.info("🛎️ \(logString, privacy: .public)")
// BLE Characteristics discovered, issue wantConfig
var toRadio: ToRadio = ToRadio()
configNonce = UInt32(NONCE_ONLY_DB)
@ -567,6 +575,7 @@ class BLEManager: NSObject, CBPeripheralDelegate, MqttClientProxyManagerDelegate
} 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
}
}