fix: slim provisioning + full reconnect on FFE2 miss #17

Closed
schwifty wants to merge 0 commits from schwifty/slim-provisioning-v2 into main
Collaborator

Summary

  • Removed frames 3-6 disable commands — cuts write sequence from 24 to 16 steps. We only configure the two frames we need (device info + iBeacon) and save. Fewer BLE writes = fewer supervision timeout disconnects.
  • Full disconnect/reconnect when FFE2 goes missing — instead of trying to rediscover characteristics on a stale GATT connection (which returns cached/missing results), we now do disconnect → reconnect → fresh service discovery → re-auth → resume write. This fixes the hang Luna identified where rediscovery never finds FFE2.
  • Guard against disconnect handler fighting with intentional FFE2 reconnects.

What changed

  • dxSmartWriteConfig() — removed 8 frame-disable commands (slots 3-6)
  • dxSmartSendNextCommand() — FFE2 missing now triggers full reconnect cycle
  • didDisconnectPeripheral — added guard for intentional FFE2 reconnect disconnects

Test plan

  • Provision a beacon — verify it completes in ~16 steps
  • Verify Frame 1 (device info) and Frame 2 (iBeacon) are configured correctly
  • Trigger an FFE2 miss scenario (if possible) — verify full reconnect recovers
  • Verify frames 3-6 are untouched after provisioning

🤖 Generated with Claude Code

## Summary - **Removed frames 3-6 disable commands** — cuts write sequence from 24 to 16 steps. We only configure the two frames we need (device info + iBeacon) and save. Fewer BLE writes = fewer supervision timeout disconnects. - **Full disconnect/reconnect when FFE2 goes missing** — instead of trying to rediscover characteristics on a stale GATT connection (which returns cached/missing results), we now do disconnect → reconnect → fresh service discovery → re-auth → resume write. This fixes the hang Luna identified where rediscovery never finds FFE2. - **Guard against disconnect handler fighting** with intentional FFE2 reconnects. ## What changed - `dxSmartWriteConfig()` — removed 8 frame-disable commands (slots 3-6) - `dxSmartSendNextCommand()` — FFE2 missing now triggers full reconnect cycle - `didDisconnectPeripheral` — added guard for intentional FFE2 reconnect disconnects ## Test plan - [ ] Provision a beacon — verify it completes in ~16 steps - [ ] Verify Frame 1 (device info) and Frame 2 (iBeacon) are configured correctly - [ ] Trigger an FFE2 miss scenario (if possible) — verify full reconnect recovers - [ ] Verify frames 3-6 are untouched after provisioning 🤖 Generated with [Claude Code](https://claude.com/claude-code)
schwifty added 2 commits 2026-03-22 03:54:46 +00:00
When FFE2 goes missing during writes, the rediscovery path had no
timeout — if CoreBluetooth never called back didDiscoverCharacteristics,
the app would hang at "Re-discovering characteristics..." indefinitely.

Adds a 5-second timeout per rediscovery attempt. If it fires, it either
retries (up to MAX_CHAR_REDISCOVERY) or fails with .timeout instead of
hanging forever.
Two key changes:

1. Remove frames 3-6 disable commands (was steps 16-23, 8 extra BLE writes).
   We only configure Frame 1 (device info) and Frame 2 (iBeacon), then save.
   Fewer writes = fewer chances for supervision timeout disconnects.

2. When FFE2 characteristic goes missing after a disconnect, do a full
   disconnect → reconnect → re-discover services → re-auth → resume cycle
   instead of trying to rediscover characteristics on the same (stale GATT)
   connection. CoreBluetooth returns cached results on the same connection,
   so FFE2 stays missing. Full reconnect forces a fresh GATT discovery.

Write sequence is now 16 steps (down from 24).

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
schwifty closed this pull request 2026-03-22 18:43:36 +00:00

Pull request closed

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#17
No description provided.