esp8266/modnetwork: Automatically do radio sleep if no interface active.
Reduces current of device by about 55mA when radio is sleeping.
This commit is contained in:
parent
9e2dd93145
commit
321d75e087
@ -102,6 +102,13 @@ void soft_reset(void) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
void init_done(void) {
|
void init_done(void) {
|
||||||
|
// Configure sleep, and put the radio to sleep if no interfaces are active
|
||||||
|
wifi_fpm_set_sleep_type(MODEM_SLEEP_T);
|
||||||
|
if (wifi_get_opmode() == NULL_MODE) {
|
||||||
|
wifi_fpm_open();
|
||||||
|
wifi_fpm_do_sleep(0xfffffff);
|
||||||
|
}
|
||||||
|
|
||||||
#if MICROPY_REPL_EVENT_DRIVEN
|
#if MICROPY_REPL_EVENT_DRIVEN
|
||||||
uart_task_init();
|
uart_task_init();
|
||||||
#endif
|
#endif
|
||||||
|
@ -83,7 +83,15 @@ STATIC mp_obj_t esp_active(size_t n_args, const mp_obj_t *args) {
|
|||||||
} else {
|
} else {
|
||||||
mode &= ~mask;
|
mode &= ~mask;
|
||||||
}
|
}
|
||||||
|
if (mode != NULL_MODE) {
|
||||||
|
wifi_fpm_do_wakeup();
|
||||||
|
wifi_fpm_close();
|
||||||
|
}
|
||||||
error_check(wifi_set_opmode(mode), "Cannot update i/f status");
|
error_check(wifi_set_opmode(mode), "Cannot update i/f status");
|
||||||
|
if (mode == NULL_MODE) {
|
||||||
|
wifi_fpm_open();
|
||||||
|
wifi_fpm_do_sleep(0xfffffff);
|
||||||
|
}
|
||||||
return mp_const_none;
|
return mp_const_none;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user