system: light and deep sleep api

see #2578

* deep sleep api without ESP class dependency
* rf + cpu light sleep for cases when deep sleep cannot be used
* generic time-based light sleep; nonos does not halt cpu,
  unlike the wakeup variant. timers also keep going, so
  this has to be used with extra care

pending some 'deferred' variant and before and after sleep actions
This commit is contained in:
Maxim Prokhorov
2023-03-10 01:14:42 +03:00
parent 28f3b7da84
commit 2f6d7ce3d3
4 changed files with 385 additions and 9 deletions

View File

@@ -275,6 +275,7 @@ void ensure_opmode(uint8_t mode) {
// since we should enforce mode changes to happen *only* through the configuration loop
if (!is_set()) {
const auto current = wifi_get_opmode();
wifi_set_opmode_current(mode);
espurna::time::blockingDelay(
@@ -287,6 +288,10 @@ void ensure_opmode(uint8_t mode) {
if (!is_set()) {
abort();
}
if (current == OpmodeNull) {
wakeupModemForcedSleep();
}
}
}