#include "esp_common.h"
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "lwip/sockets.h"
#include "lwip/dns.h"
#include "lwip/netdb.h"
#include "uart.h"
void ICACHE_FLASH_ATTR
adc_task(void *pvParameters)
{
while(1)
{
unsigned short read_adc;
/*返回值单位:1/1024 V*/
read_adc = system_adc_read();
printf("READ ADC: %d\r\n", read_adc);
vTaskDelay(1000 / portTICK_RATE_MS);
printf("TM:%u: SM:%u, WIFI STATE: %u\n", system_get_time(), system_get_free_heap_size(), wifi_station_get_connect_status());
}
}
/******************************************************************************
* FunctionName : user_init
* Description : entry of user application, init user function here
* Parameters : none
* Returns : none
*******************************************************************************/
void ICACHE_FLASH_ATTR
user_init(void)
{
uart_init_new();
printf("SDK version:%s\n", system_get_sdk_version());
/* need to set opmode before you set config */
wifi_set_opmode(STATION_MODE);
struct station_config *config = (struct station_config *)malloc(sizeof(struct station_config));
memset(config, 0, sizeof(struct station_config));
sprintf(config->ssid, "Netcore");
sprintf(config->password, "");
/* need to sure that you are in station mode first,
* otherwise it will be failed. */
wifi_station_set_config(config);
//wifi_station_set_auto_connect(1);
free(config);
xTaskCreate(adc_task, "adc_task", 256, NULL, 2, NULL);
}
出现问题的log如下:
reconnect
TM:1316648810: SM:56792, WIFI STATE: 3
READ ADC: 206
TM:1317648811: SM:56792, WIFI STATE: 3
READ ADC: 206
scandone
no Netcore found, reconnect after 1s
reconnect
TM:1318648816: SM:56792, WIFI STATE: 3
READ ADC: 206
TM:1319648810: SM:56792, WIFI STATE: 3
READ ADC: 1024
scandone
no Netcore found, reconnect after 1s
reconnect
TM:1320648811: SM:56792, WIFI STATE: 3
READ ADC: 1024
TM:1321648810: SM:56792, WIFI STATE: 3
READ ADC: 1024Statistics: Posted by Lucifer3502 — Sat Dec 12, 2015 8:02 am
]]>