ESPHome 2026.5.0b1
Loading...
Searching...
No Matches
deep_sleep_zephyr.cpp
Go to the documentation of this file.
2#ifdef USE_ZEPHYR
3#include "esphome/core/log.h"
4#include "esphome/core/wake.h"
5#include <zephyr/sys/poweroff.h>
6
7namespace esphome::deep_sleep {
8
9static const char *const TAG = "deep_sleep";
10
11optional<uint32_t> DeepSleepComponent::get_run_duration_() const { return this->run_duration_; }
12
14
15bool DeepSleepComponent::prepare_to_sleep_() { return true; }
16
18 if (this->sleep_duration_.has_value()) {
20 } else {
21#ifndef USE_ZIGBEE
22 // the device can be woken up through one of the following signals:
23 // - The DETECT signal, optionally generated by the GPIO peripheral.
24 // - The ANADETECT signal, optionally generated by the LPCOMP module.
25 // - The SENSE signal, optionally generated by the NFC module to wake-on-field.
26 // - Detecting a valid USB voltage on the VBUS pin (VBUS,DETECT).
27 // - A reset.
28 //
29 // The system is reset when it wakes up from System OFF mode.
30 sys_poweroff();
31#else
33#endif
34 }
35 const bool woke = esphome::wake_request_take();
36 if (woke) {
37 ESP_LOGD(TAG, "Woken up by another thread");
38 } else {
39 ESP_LOGD(TAG, "Timeout expired (normal sleep)");
40 }
41}
42
44 if (this->sleep_duration_.has_value()) {
45 return false;
46 }
47#ifdef USE_ZIGBEE
48 return false;
49#else
50 return true;
51#endif
52}
53
54} // namespace esphome::deep_sleep
55
56#endif
optional< uint32_t > get_run_duration_() const
void ESPHOME_ALWAYS_INLINE wakeable_delay(uint32_t ms)
Host wakeable_delay uses select() over the registered fds — defined in wake_host.cpp.
static void uint32_t
Platform-specific main loop wake primitives.