Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions examples/companion_radio/MyMesh.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2144,3 +2144,11 @@ bool MyMesh::advert() {
return false;
}
}

// To check if there is pending work
bool MyMesh::hasPendingWork() const {
#if defined(WITH_BRIDGE)
if (bridge.isRunning()) return true; // bridge needs WiFi radio, can't sleep
#endif
return _mgr->getOutboundTotal() > 0;
}
3 changes: 3 additions & 0 deletions examples/companion_radio/MyMesh.h
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,9 @@ class MyMesh : public BaseChatMesh, public DataStoreHost {
}
#endif

// To check if there is pending work
bool hasPendingWork() const;

private:
void writeOKFrame();
void writeErrFrame(uint8_t err_code);
Expand Down
6 changes: 6 additions & 0 deletions examples/companion_radio/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -229,4 +229,10 @@ void loop() {
ui_task.loop();
#endif
rtc_clock.tick();

if (!the_mesh.hasPendingWork()) {
#if defined(NRF52_PLATFORM)
board.sleep(0); // nrf ignores seconds param, sleeps whenever possible
#endif
}
}
Loading