fix: handle expected BLE disconnect after SaveConfig command
The DX-Smart CP28 beacon reboots after receiving SaveConfig (0x60) to persist config to flash. This drops the BLE connection before the write callback fires, causing the app to report "Unexpected disconnect" even though the config was successfully saved. Now we check if we're on the last command (SaveConfig) when disconnect occurs — if so, treat it as success instead of failure. Co-Authored-By: Luna <luna@payfrit.com>
This commit is contained in:
parent
9c984b954a
commit
e387b9ceb1
1 changed files with 5 additions and 0 deletions
|
|
@ -974,6 +974,11 @@ extension BeaconProvisioner: CBCentralManagerDelegate {
|
|||
} else if state != .success && state != .idle {
|
||||
if case .failed = state {
|
||||
// Already failed
|
||||
} else if state == .writing && dxSmartWriteIndex >= dxSmartCommandQueue.count - 1 {
|
||||
// SaveConfig (last command) was sent — beacon rebooted to apply config
|
||||
// This is expected behavior, treat as success
|
||||
DebugLog.shared.log("BLE: Disconnect after SaveConfig — treating as success")
|
||||
succeed()
|
||||
} else {
|
||||
fail("Unexpected disconnect", code: .disconnected)
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue