Skip to content

Add periodic keep-alive to prevent cameras from silently sleeping#76

Merged
kmatzen merged 5 commits intomainfrom
feature/keep-alive-timer
Feb 22, 2026
Merged

Add periodic keep-alive to prevent cameras from silently sleeping#76
kmatzen merged 5 commits intomainfrom
feature/keep-alive-timer

Conversation

@kmatzen
Copy link
Copy Markdown
Owner

@kmatzen kmatzen commented Feb 22, 2026

Summary

  • Sends BLE Keep Alive messages (command 0x5B) to all connected cameras every 3 seconds via the Settings characteristic, per the Open GoPro API best practices
  • Prevents cameras from auto-sleeping while the app considers them connected, which previously caused invalid state and USB connectivity issues
  • Timer lifecycle is managed cleanly: starts on first camera connect, stops on last disconnect, and is explicitly stopped before sleep/power-down commands

Test plan

  • Connect cameras and verify they stay awake indefinitely (no auto-sleep)
  • Use the sleep button and verify cameras sleep cleanly
  • Reconnect cameras after sleep and verify normal operation
  • Verify USB connectivity works after a clean sleep cycle

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 feature/keep-alive-timer branch from 19aad9b to 889c85f Compare February 22, 2026 19:30
Kevin Blackburn-Matzen and others added 4 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>
Group status now reflects the least-progressed camera in the group,
making the state progression predictable: disconnected → connecting →
initializing → ready. Errors and recording override since they require
immediate attention. The status message continues to show the detailed
per-state breakdown.

Co-authored-by: Cursor <cursoragent@cursor.com>
GoPro cameras auto-sleep when both the Auto Power Down and Keep Alive
timers expire. Without periodic keep-alive messages, connected cameras
could silently enter sleep while the app still considered them active,
leading to an invalid state that also affected USB connectivity.

Sends Keep Alive (0x5B) to all connected cameras every 3 seconds via
the Settings characteristic, per Open GoPro API best practices. The
timer starts when the first camera connects and stops on last disconnect
or before explicit sleep/power-down commands.

Co-authored-by: Cursor <cursoragent@cursor.com>
@kmatzen kmatzen force-pushed the feature/keep-alive-timer branch from 889c85f to bb89732 Compare February 22, 2026 19:35
@kmatzen kmatzen merged commit e93d71c into main Feb 22, 2026
1 check passed
@kmatzen kmatzen deleted the feature/keep-alive-timer branch February 22, 2026 19:45
@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