所以我想问一下,是否系统中有什么其他的定时器在跑?如果有的话是否可以关掉?能关掉的话接口可否说明一下?
若系统应用中有小于 DTIM Beacon 间隔时间的循环定时,系统将不能进入 Light-sleep 模式。
Statistics: Posted by greenu — Fri Jan 06, 2017 1:18 pm
Statistics: Posted by ESP_Xutao — Thu Jan 05, 2017 2:21 pm
Code:
void user_esp_platform_check_ip(void)
{
struct ip_info ipconfig;
os_timer_disarm(&g_check_ip_timer);
wifi_station_set_hostname("8266_test");
wifi_get_ip_info(STATION_IF, &ipconfig);
if (wifi_station_get_connect_status() == STATION_GOT_IP
&& ipconfig.ip.addr != 0)
{
os_printf("got ip\r\n");
//set sleep type
if (wifi_set_sleep_type(LIGHT_SLEEP_T))
os_printf("sleep success\r\n");
else
os_printf("sleep fail\r\n");
}
else
{
if (wifi_station_get_connect_status() == STATION_WRONG_PASSWORD ||
wifi_station_get_connect_status() == STATION_NO_AP_FOUND ||
wifi_station_get_connect_status() == STATION_CONNECT_FAIL)
{
os_printf("connect fail\r\n");
}
else
{
os_timer_setfn(&g_check_ip_timer, (os_timer_func_t*)user_esp_platform_check_ip, NULL);
os_timer_arm(&g_check_ip_timer, 200, 0);
}
}
}
void wifi_config(void)
{
char ssid[32] = "******";
char password[64] = "******";
struct station_config station_cfg = {0};
os_printf("wifi config\r\n");
os_memcpy(&station_cfg.ssid, ssid, 32);
os_memcpy(&station_cfg.password, password, 64);
wifi_station_set_config(&station_cfg);
os_timer_disarm(&g_check_ip_timer);
os_timer_setfn(&g_check_ip_timer, (os_timer_func_t*)user_esp_platform_check_ip, NULL);
os_timer_arm(&g_check_ip_timer, 200, 0);
}
void user_init(void)
{
uart_init(115200, 115200);
wifi_set_opmode(STATION_MODE);
wifi_config();
}
Statistics: Posted by greenu — Wed Jan 04, 2017 7:53 pm