Skip to content

Commit 07e7e2d

Browse files
yardafschrempf
authored andcommitted
companion: Suspend radio when hibernating
This should significantly reduce power consumption in hibernation. Fixes: #1014 Signed-off-by: Jaroslav Škarvada <[email protected]> Signed-off-by: Frieder Schrempf <[email protected]> # generalize for all radios and UIs
1 parent f5a56c5 commit 07e7e2d

File tree

4 files changed

+9
-2
lines changed

4 files changed

+9
-2
lines changed

examples/companion_radio/ui-new/UITask.cpp

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -650,6 +650,7 @@ void UITask::shutdown(bool restart){
650650
_board->reboot();
651651
} else {
652652
_display->turnOff();
653+
radio_driver.powerOff();
653654
_board->powerOff();
654655
}
655656
}

examples/companion_radio/ui-orig/UITask.cpp

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -292,10 +292,12 @@ void UITask::shutdown(bool restart){
292292

293293
#endif // PIN_BUZZER
294294

295-
if (restart)
295+
if (restart) {
296296
_board->reboot();
297-
else
297+
} else {
298+
radio_driver.powerOff();
298299
_board->powerOff();
300+
}
299301
}
300302

301303
void UITask::loop() {

src/helpers/radiolib/CustomSX1262Wrapper.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,4 +19,7 @@ class CustomSX1262Wrapper : public RadioLibWrapper {
1919
int sf = ((CustomSX1262 *)_radio)->spreadingFactor;
2020
return packetScoreInt(snr, sf, packet_len);
2121
}
22+
virtual void powerOff() override {
23+
((CustomSX1262 *)_radio)->sleep(false);
24+
}
2225
};

src/helpers/radiolib/RadioLibWrappers.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ class RadioLibWrapper : public mesh::Radio {
2121
RadioLibWrapper(PhysicalLayer& radio, mesh::MainBoard& board) : _radio(&radio), _board(&board) { n_recv = n_sent = 0; }
2222

2323
void begin() override;
24+
virtual void powerOff() { _radio->sleep(); }
2425
int recvRaw(uint8_t* bytes, int sz) override;
2526
uint32_t getEstAirtimeFor(int len_bytes) override;
2627
bool startSendRaw(const uint8_t* bytes, int len) override;

0 commit comments

Comments
 (0)