fix: connection callback bug + provisioning diagnostics #34

Merged
schwifty merged 1 commit from schwifty/provision-diagnostics into main 2026-03-22 23:12:32 +00:00
Collaborator

Bug Fix

Root cause found: All provisioners called centralManager.connect() but BLEManager was the only CBCentralManagerDelegate. BLEManager never implemented didConnect or didFailToConnect, so provisioner connection continuations were never resumed — they always hit the 5-second timeout.

This means provisioning has been impossible through the modular provisioner path.

Fix

  1. Added didConnect, didFailToConnect, didDisconnectPeripheral to BLEManager's CBCentralManagerDelegate
  2. Provisioners register connection callbacks via bleManager reference
  3. Increased connection timeout from 5s → 10s (BLE can be slow)

Diagnostics

Added ProvisionLog — a timestamped diagnostic log that captures every provisioning step:

  • Init (beacon type, RSSI, service point)
  • API calls (minor allocation)
  • Connection attempts and retries
  • Service/characteristic discovery
  • Auth steps
  • Write commands (per-command for DXSmart)
  • Errors with full context

On failure, the log is displayed in the UI with a Share button so John can screenshot or share the full trace.

Files Changed

  • BLEManager.swift — added missing CBCentralManagerDelegate methods + connection callback closures
  • ProvisionerProtocol.swift — added bleManager and diagnosticLog to protocol
  • DXSmartProvisioner.swift — connection fix + full diagnostic logging
  • KBeaconProvisioner.swift — connection fix
  • BlueCharmProvisioner.swift — connection fix
  • FallbackProvisioner.swift — passes through bleManager/log to child provisioners
  • ScanView.swift — wires up diagnostics, shows log on failure
  • ProvisionLog.swift — new diagnostic log service
## Bug Fix **Root cause found**: All provisioners called `centralManager.connect()` but BLEManager was the only `CBCentralManagerDelegate`. BLEManager never implemented `didConnect` or `didFailToConnect`, so provisioner connection continuations were **never resumed** — they always hit the 5-second timeout. This means provisioning has been impossible through the modular provisioner path. ### Fix 1. Added `didConnect`, `didFailToConnect`, `didDisconnectPeripheral` to BLEManager's CBCentralManagerDelegate 2. Provisioners register connection callbacks via `bleManager` reference 3. Increased connection timeout from 5s → 10s (BLE can be slow) ## Diagnostics Added `ProvisionLog` — a timestamped diagnostic log that captures every provisioning step: - Init (beacon type, RSSI, service point) - API calls (minor allocation) - Connection attempts and retries - Service/characteristic discovery - Auth steps - Write commands (per-command for DXSmart) - Errors with full context On failure, the log is displayed in the UI with a **Share** button so John can screenshot or share the full trace. ## Files Changed - `BLEManager.swift` — added missing CBCentralManagerDelegate methods + connection callback closures - `ProvisionerProtocol.swift` — added `bleManager` and `diagnosticLog` to protocol - `DXSmartProvisioner.swift` — connection fix + full diagnostic logging - `KBeaconProvisioner.swift` — connection fix - `BlueCharmProvisioner.swift` — connection fix - `FallbackProvisioner.swift` — passes through bleManager/log to child provisioners - `ScanView.swift` — wires up diagnostics, shows log on failure - `ProvisionLog.swift` — new diagnostic log service
schwifty added 1 commit 2026-03-22 23:12:25 +00:00
BIG FIX: Provisioners were calling centralManager.connect() but
BLEManager is the CBCentralManagerDelegate — provisioners never
received didConnect/didFailToConnect callbacks, so connections
ALWAYS timed out after 5s regardless. This is why provisioning
kept failing. Fixed by:
1. Adding didConnect/didFailToConnect/didDisconnect to BLEManager
2. Provisioners register connection callbacks via bleManager
3. Increased connection timeout from 5s to 10s

DIAGNOSTICS: Added ProvisionLog system so failures show a timestamped
step-by-step log of what happened (with Share button). Every phase
is logged: init, API calls, connect attempts, service discovery,
auth, write commands, and errors.
schwifty merged commit 349dab1b75 into main 2026-03-22 23:12:32 +00:00
Sign in to join this conversation.
No reviewers
No labels
No milestone
No project
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: payfrit/payfrit-beacon-ios#34
No description provided.