Skip to content

fix: keep BLE connection alive while app is open - #940

Open
bettythegoodboi wants to merge 2 commits into
GameTec-live:mainfrom
bettythegoodboi:pr/ble-connection-keepalive
Open

fix: keep BLE connection alive while app is open#940
bettythegoodboi wants to merge 2 commits into
GameTec-live:mainfrom
bettythegoodboi:pr/ble-connection-keepalive

Conversation

@bettythegoodboi

Copy link
Copy Markdown

Summary

Android often drops idle BLE when the phone sleeps; the Ultra then enters system-off ~4s after BLE disconnect (firmware does not sleep while BLE is connected).

  • Enable wakelock while connected and app is in foreground (DFU still forces wakelock)
  • Periodic lightweight firmware ping every 12s to keep BLE busy
  • Request high-performance BLE connection priority on Android after connect
  • Soft-fail: retry 3 times per tick (800ms apart), disconnect only after 3 consecutive failed ticks (~36s of real failure)
  • Add WAKE_LOCK permission

Test plan

  • Connect via BLE on Android, leave idle on Home/Slot Manager for several minutes without disconnect
  • Screen stays on while connected in foreground; releases after disconnect
  • DFU / flash still works with wakelock
  • Weak BLE: single glitch does not immediately disconnect
  • USB connection still works (ping + wakelock only while connected)

ytchua added 2 commits July 19, 2026 04:21
Android often drops idle BLE when the phone sleeps; firmware then
enters system-off ~4s after BLE disconnects. While BLE is connected
the device itself already refuses to sleep.

- Wakelock while connected and app is in the foreground
- Periodic lightweight firmware ping every 12s to keep BLE busy
- Request high-performance BLE connection priority on Android
- Add WAKE_LOCK permission
@GameTec-live

Copy link
Copy Markdown
Owner

For reference: How much of this is AI and did you manually test and review the code?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Todo

Development

Successfully merging this pull request may close these issues.

3 participants