Skip to content

Reduce log noise, fix queue timer bug, and add auto-reconnect#74

Merged
kmatzen merged 3 commits intomainfrom
fix/log-noise-and-auto-reconnect
Feb 22, 2026
Merged

Reduce log noise, fix queue timer bug, and add auto-reconnect#74
kmatzen merged 3 commits intomainfrom
fix/log-noise-and-auto-reconnect

Conversation

@kmatzen
Copy link
Copy Markdown
Owner

@kmatzen kmatzen commented Feb 22, 2026

Summary

  • Fix command queue timer race condition: startCommandQueueTimer deferred timer creation via DispatchQueue.main.async, allowing multiple orphaned timers per camera. One camera alone generated 1,400+ spurious debug messages. Now creates timers synchronously with proper invalidation.
  • Add auto-reconnect for dropped cameras: When a camera disconnects unexpectedly and the group is in a connected state (targetConnectedCameras), the straggler retry timer restarts to reconnect it (up to 5 attempts, 15s interval). Intentional disconnects (sleep, power down, disconnect all) remove cameras from the target set.
  • Handle GoPro status types 4/5: Silently ignore "System Hot" (type 4) and "System Busy" (type 5) instead of logging 221+ "Unknown status type" messages per session.
  • Downgrade BLE setup logs to DEBUG: Per-characteristic discovery (90 messages) and subscription (36 messages) moved from INFO to DEBUG. Single summary line per camera instead.
  • Clean up connection retry logging: "Starting connection retry", "Connection attempt 1/3", and "Connection successful" downgraded from INFO to DEBUG — redundant with the existing "Connected to GoPro X" INFO log.
  • Reduce connection timeout: 30s → 15s. With staggered connections (0.5s apart), even the last camera gets ~10s of actual connection time.

Test plan

  • Verified queue timer spam is eliminated (was 1,400+ messages, now 0)
  • Verified "Unknown status type" messages are gone
  • Verified characteristic discovery logs consolidated to single DEBUG line per camera
  • Verified connection timeout reduced to 15s
  • Tested auto-reconnect: camera drop detected, reconnect scheduled
  • Verified intentional sleep/disconnect does not trigger reconnect

Made with Cursor

GroupStatus.overallStatus incorrectly reported "Settings Mismatch" whenever
cameras were disconnected, even if all connected cameras matched. Now it
properly tracks per-camera settings/mode mismatch counts and only shows
"Ready" when every camera in the group is accounted for.

Also staggers recording commands (50ms apart) to reduce BLE congestion,
logs encoding state transitions per camera, and downgrades mode mismatch
check logging to DEBUG when no mismatches exist.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kmatzen kmatzen force-pushed the fix/log-noise-and-auto-reconnect branch from 965f487 to 6d8aec1 Compare February 22, 2026 19:30
Kevin Blackburn-Matzen and others added 2 commits February 22, 2026 11:33
Add settingsMismatchCameras and modeMismatchCameras to GroupStatus
init calls in test helper to match the updated struct.

Co-authored-by: Cursor <cursoragent@cursor.com>
Fix command queue timer race condition where multiple timers were created
for the same camera due to async timer creation, causing hundreds of
spurious "queue is empty" messages. Timer creation is now synchronous on
the main thread with proper invalidation of existing timers.

Add auto-reconnect for cameras that drop unexpectedly while the group is
in a connected state. Uses the existing straggler retry mechanism (up to
5 attempts, 15s interval). Intentional disconnects (sleep, power down)
remove cameras from the target set to prevent unwanted reconnection.

Also: handle GoPro status types 4/5 to eliminate "Unknown status type"
spam, downgrade per-characteristic discovery and connection retry logs
from INFO to DEBUG, and reduce connection timeout from 30s to 15s.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kmatzen kmatzen force-pushed the fix/log-noise-and-auto-reconnect branch from 6d8aec1 to 5b0adc7 Compare February 22, 2026 19:35
@kmatzen kmatzen merged commit 5b0adc7 into main Feb 22, 2026
1 check passed
@kmatzen kmatzen mentioned this pull request Feb 22, 2026
15 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant