fix: handle disconnect during device info read phase
The disconnect handler didn't account for awaitingDeviceInfoForProvisioning state, causing it to fall through to the generic "Unexpected disconnect" error. Since the MAC address read is optional (timeout already skips it), this disconnect is now caught explicitly with a clear retriable message. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
parent
f7a554e282
commit
d97db702f7
1 changed files with 7 additions and 0 deletions
|
|
@ -980,6 +980,13 @@ extension BeaconProvisioner: CBCentralManagerDelegate {
|
|||
// This is expected behavior, treat as success
|
||||
DebugLog.shared.log("BLE: Disconnect after SaveConfig (idx=\(dxSmartWriteIndex)/\(dxSmartCommandQueue.count)) — treating as success")
|
||||
succeed()
|
||||
} else if awaitingDeviceInfoForProvisioning {
|
||||
// Disconnect during device info read (MAC query) — MAC is optional,
|
||||
// so this is non-critical. Clear the flag and fail gracefully with a
|
||||
// retriable error instead of the generic "Unexpected disconnect".
|
||||
DebugLog.shared.log("BLE: Disconnect during device info read — MAC is optional, treating as retriable")
|
||||
awaitingDeviceInfoForProvisioning = false
|
||||
fail("Disconnected while reading device info — please retry", code: .disconnected)
|
||||
} else {
|
||||
DebugLog.shared.log("BLE: UNEXPECTED disconnect — state=\(state) writeIdx=\(dxSmartWriteIndex) queueCount=\(dxSmartCommandQueue.count)")
|
||||
fail("Unexpected disconnect", code: .disconnected)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue