Skip to content

Prevent device sleep during WiFi file transfer and OTA updates#203

Merged
daveallie merged 1 commit intocrosspoint-reader:masterfrom
bigbag:fix/sleep-on-wifi
Jan 2, 2026
Merged

Prevent device sleep during WiFi file transfer and OTA updates#203
daveallie merged 1 commit intocrosspoint-reader:masterfrom
bigbag:fix/sleep-on-wifi

Conversation

@bigbag
Copy link
Contributor

@bigbag bigbag commented Jan 1, 2026

Summary

  • What is the goal of this PR? Fixes Device can fall asleep during wifi file transfer #199 - Device falls asleep during WiFi file transfer after 10 minutes of inactivity, disconnecting the web server.

  • What changes are included?

    • Add preventAutoSleep() virtual method to Activity base class
    • Modify main loop to reset inactivity timer when preventAutoSleep() returns true
    • Override preventAutoSleep() in CrossPointWebServerActivity (returns true when web server running)
    • Override preventAutoSleep() in OtaUpdateActivity (returns true during update check/download)

Additional Context

  • The existing skipLoopDelay() method controls loop timing (yield vs delay) for HTTP responsiveness. The new preventAutoSleep() method is semantically separate - it explicitly signals that an activity should keep the device awake.
  • CrossPointWebServerActivity uses both methods: skipLoopDelay() for responsive HTTP handling, preventAutoSleep() for staying awake.
  • OtaUpdateActivity only needs preventAutoSleep() since the OTA library handles HTTP internally.

  Fixes #199 - device would auto-sleep after 10 minutes while webserver
  was running. Adds preventAutoSleep() method to Activity base class,
  allowing activities to signal they should keep the device awake.
@daveallie
Copy link
Member

Thanks for this!

@daveallie daveallie merged commit a922e55 into crosspoint-reader:master Jan 2, 2026
1 check passed
@bigbag bigbag deleted the fix/sleep-on-wifi branch January 14, 2026 05:44
yingirene pushed a commit to yingirene/crosspoint-reader that referenced this pull request Jan 16, 2026
…point-reader#203)

## Summary

* **What is the goal of this PR?** Fixes crosspoint-reader#199 - Device falls asleep
during WiFi file transfer after 10 minutes of inactivity, disconnecting
the web server.

  * **What changes are included?**
    - Add `preventAutoSleep()` virtual method to `Activity` base class
- Modify main loop to reset inactivity timer when `preventAutoSleep()`
returns true
- Override `preventAutoSleep()` in `CrossPointWebServerActivity`
(returns true when web server running)
- Override `preventAutoSleep()` in `OtaUpdateActivity` (returns true
during update check/download)

  ## Additional Context

* The existing `skipLoopDelay()` method controls loop timing (yield vs
delay) for HTTP responsiveness. The new `preventAutoSleep()` method is
semantically separate - it explicitly signals that an activity should
keep the device awake.
* `CrossPointWebServerActivity` uses both methods: `skipLoopDelay()` for
responsive HTTP handling, `preventAutoSleep()` for staying awake.
* `OtaUpdateActivity` only needs `preventAutoSleep()` since the OTA
library handles HTTP internally.
Unintendedsideeffects pushed a commit to Unintendedsideeffects/crosspoint-reader that referenced this pull request Feb 17, 2026
…point-reader#203)

## Summary

* **What is the goal of this PR?** Fixes crosspoint-reader#199 - Device falls asleep
during WiFi file transfer after 10 minutes of inactivity, disconnecting
the web server.

  * **What changes are included?**
    - Add `preventAutoSleep()` virtual method to `Activity` base class
- Modify main loop to reset inactivity timer when `preventAutoSleep()`
returns true
- Override `preventAutoSleep()` in `CrossPointWebServerActivity`
(returns true when web server running)
- Override `preventAutoSleep()` in `OtaUpdateActivity` (returns true
during update check/download)

  ## Additional Context

* The existing `skipLoopDelay()` method controls loop timing (yield vs
delay) for HTTP responsiveness. The new `preventAutoSleep()` method is
semantically separate - it explicitly signals that an activity should
keep the device awake.
* `CrossPointWebServerActivity` uses both methods: `skipLoopDelay()` for
responsive HTTP handling, `preventAutoSleep()` for staying awake.
* `OtaUpdateActivity` only needs `preventAutoSleep()` since the OTA
library handles HTTP internally.
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.

Device can fall asleep during wifi file transfer

2 participants