diff options
author | Damien George <damien.p.george@gmail.com> | 2019-01-31 00:05:00 +1100 |
---|---|---|
committer | Damien George <damien.p.george@gmail.com> | 2019-01-31 00:05:00 +1100 |
commit | 3ff3e968656cd01144c0b92e2f0cf4195740255d (patch) | |
tree | 343eec9e7636ab2d72fb551b31a812e1ef4f84a1 | |
parent | 4dfcc255d5ebe8625b87e5b923db9e22166bb9b4 (diff) |
esp8266/modmachine: In lightsleep, only waiti if wifi is turned off.
Otherwise the STA interface can't do DTIM sleeping correctly and power
consumption goes up.
-rw-r--r-- | ports/esp8266/modmachine.c | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/ports/esp8266/modmachine.c b/ports/esp8266/modmachine.c index 11fb19cd2..8c3905161 100644 --- a/ports/esp8266/modmachine.c +++ b/ports/esp8266/modmachine.c @@ -105,10 +105,14 @@ STATIC mp_obj_t machine_lightsleep(size_t n_args, const mp_obj_t *args) { } max_us = max_ms * 1000; } + uint32_t wifi_mode = wifi_get_opmode(); uint32_t start = system_get_time(); while (system_get_time() - start <= max_us) { ets_event_poll(); - asm("waiti 0"); + if (wifi_mode == NULL_MODE) { + // Can only idle if the wifi is off + asm("waiti 0"); + } } return mp_const_none; } |