在NodeMCU中强制轻度睡眠模式

时间:2016-05-21 20:18:07

标签: esp8266 nodemcu

RTOS SDK文档有以下示例C代码:

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);  

NodeMCU会暴露这些吗?

1 个答案:

答案 0 :(得分:1)

期待wifi.c中的wifi.sleep nodemcu的实施:

//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);
...
}

然后,为了使用wifi_fpm_set_sleep_type来调用LIGHT_SLEEP_T,您需要修改nodemcu,对于唤醒,您可能需要在输入更改时调用wifi.sleep(0)