Mark McGinty
Mark McGinty

Reputation: 756

Forcing light sleep mode in NodeMCU

The RTOS SDK docs have this sample C code:

wifi_set_opmode(NULL_MODE);    // set WiFi mode to null mode.
wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); // light sleep
wifi_fpm_open();  
PIN_FUNC_SELECT(PERIPHS_IO_MUX_MTCK_U,3);
gpio_pin_wakeup_enable(13, GPIO_PIN_INTR_LOLEVEL);
wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1); // Set wakeup callback
wifi_fpm_do_sleep(0xFFFFFFF);  

Does NodeMCU expose any of this?

Upvotes: 0

Views: 2798

Answers (1)

mpromonet
mpromonet

Reputation: 11952

Looking to wifi.sleep implementation of nodemcu in wifi.c :

//wifi.sleep()
static int wifi_sleep(lua_State* L)
{
...
    // set WiFi mode to null mode
wifi_set_opmode(NULL_MODE);
// set force sleep type
wifi_fpm_set_sleep_type(MODEM_SLEEP_T);
wifi_fpm_open();
wifi_fpm_do_sleep_return_value = wifi_fpm_do_sleep(FPM_SLEEP_MAX_TIME);
...
}

Then in order to call wifi_fpm_set_sleep_type with LIGHT_SLEEP_T, you will need to modify nodemcu and for wakeup you probably need call wifi.sleep(0) when input change.

Upvotes: 1

Related Questions