fix: broaden disconnect retry to cover all active provisioning phases

Previously retry logic only caught disconnects during .authenticating
and .writing states. Beacons can also drop during .discoveringServices
(characteristic discovery) and .verifying (broadcast check), which
would bypass retry and immediately hard-fail.

Now all active provisioning phases get the same reconnect retry
treatment with backoff delays.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
Schwifty 2026-03-22 00:23:01 +00:00
parent 34e8ea0bab
commit 28aefd1bdf

View file

@ -1041,8 +1041,9 @@ extension BeaconProvisioner: CBCentralManagerDelegate {
return
}
// Unexpected disconnect during auth or writing retry with full reconnect
if (state == .authenticating || state == .writing) && disconnectRetryCount < BeaconProvisioner.MAX_DISCONNECT_RETRIES {
// Unexpected disconnect during any active provisioning phase retry with full reconnect
let isActivePhase = (state == .discoveringServices || state == .authenticating || state == .writing || state == .verifying)
if isActivePhase && disconnectRetryCount < BeaconProvisioner.MAX_DISCONNECT_RETRIES {
disconnectRetryCount += 1
DebugLog.shared.log("BLE: Disconnect during \(state) — reconnecting (attempt \(disconnectRetryCount)/\(BeaconProvisioner.MAX_DISCONNECT_RETRIES))")
progress = "Beacon disconnected, reconnecting (\(disconnectRetryCount)/\(BeaconProvisioner.MAX_DISCONNECT_RETRIES))..."