Chat freely about anything...

User avatar
By Martin Bolino
#88404 Colleagues,

I am confused on a way to get forced light sleep and actually wake up . According to the latest doc ESP8266 Non-OS SDK API Reference ver 3.0.1 from 2019 , there is a function wifi_fpm_do_sleep that enables to define timeout for sleep .
int8 wifi_fpm_do_sleep (uint32 sleep_time_in_us)

uint32 sleep_time_in_us: sleep time, ESP8266 will wake up automatically on time out. Unit: us. Range: 10000 ~ 268435455(0xFFFFFFF)
• If sleep_time_in_us is 0xFFFFFFF, the ESP8266 will sleep till be woke up as below:
• If wifi_fpm_set_sleep_type is set to be LIGHT_SLEEP_T, ESP8266 can wake up by GPIO.
• If wifi_fpm_set_sleep_type is set to be MODEM_SLEEP_T, ESP8266 can wake up by wifi_fpm_do_wakeup.

So, to confirm, it looks from here that if timeout is different to 0xffffff we can wake the esp8266 without using any external event . Is this correct?

This is the code example in same doc(that is not working for me)

void fpm_wakup_cb_func1(void)
{
wifi_fpm_close(); // disable force sleep function
wifi_set_opmode(STATION_MODE); // set station mode
wifi_station_connect(); // connect to AP
}

void user_func(...)
{
wifi_station_disconnect();
wifi_set_opmode(NULL_MODE); // set WiFi mode to null mode.
wifi_fpm_set_sleep_type(LIGHT_SLEEP_T); // light sleep
wifi_fpm_open(); // enable force sleep
wifi_fpm_set_wakeup_cb(fpm_wakup_cb_func1); // Set wakeup callback
wifi_fpm_do_sleep(50*1000); //here I put my delay, for example (20000000) , 20 secs, but it does not work.
}

Any feedback from the field?