-
Notifications
You must be signed in to change notification settings - Fork 757
nrf52: allow companion to sleep when idle #1682
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: dev
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -225,4 +225,9 @@ void loop() { | |||||||||||
| ui_task.loop(); | ||||||||||||
| #endif | ||||||||||||
| rtc_clock.tick(); | ||||||||||||
|
|
||||||||||||
| #if defined(NRF52_PLATFORM) | ||||||||||||
| board.sleep(1800); | ||||||||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
This is probably sufficient, but even without it the code should still work, but it sleeps an additional millisecond? :) There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I concur, added a similar check to my version. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Sleep on NRF52 is event-based, not time-based. See |
||||||||||||
| #endif | ||||||||||||
|
|
||||||||||||
| } | ||||||||||||
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Maybe?
Probably need to add hasPendingWork(), _mgr->getOutboundCount(0xFFFFFFFF) > 0 - not sure if it's actually useful.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Seems like the right direction.
board.sleep()is unconditional here, so this does not actually implement “sleep when idle”. On nRF52NRF52Board::sleep()is a blocking sd_app_evt_wait() / __WFE() wait (src/helpers/NRF52Board.cpp:254), which means every companion build now becomes interrupt-paced even whileMyMesh::loop()still has active serial or radio work to drain. That is a behavior change from the existing repeater logic, which only sleeps after!the_mesh.hasPendingWork()(examples/simple_repeater/main.cpp:137). If the intent is only idle power saving, this needs an explicit idle predicate; otherwise active USB/BLE sessions and contact syncs now pay an avoidable wait on every loop iteration.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think just checking outbound is an easy extra, it will wakeup regardless though.