#include <string.h>
#include <stdbool.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "freertos/queue.h"
#include "esp_system.h"
#include "esp_event.h"
#include "esp_log.h"
#include "lwip/err.h"
#include "lwip/sys.h"
#include "zmgccs_main.h"
#include "esp_netif.h"
#include "wifi_service.h"
#include "smart_config.h"
#include "tcpip_adapter.h"
#include "tcpip_adapter_types.h"
#include "doMP3.h"
char *TAG_WIFI = "zmg-WIFI";
static int s_retry_num = 0;
static periph_service_handle_t wifi_serv;
static bool is_smart_config = false;
static wifi_service_event_t wifi_serv_stat= WIFI_SERV_EVENT_UNKNOWN;
//主任务会间隔5秒调用一次WiFi连接函数
esp_err_t wifi_connecting(bool reconnect)
{
wifi_config_t wifi_config;
if (wifi_serv_stat != WIFI_SERV_EVENT_CONNECTED && reconnect)
{ //还未连接重新连接
if (is_smart_config)
{
wifi_service_setting_stop(wifi_serv,0);
is_smart_config = false;
} else {
wifi_service_disconnect(wifi_serv);
}
memset(wifi_config.sta.ssid,0,sizeof(wifi_config.sta.ssid));
memcpy(wifi_config.sta.ssid ,hd_param.WIFI_SSID,sizeof(hd_param.WIFI_SSID));
memset(wifi_config.sta.password,0,sizeof(wifi_config.sta.password));
memcpy(wifi_config.sta.password ,hd_param.WIFI_PASSWORD,sizeof(hd_param.WIFI_PASSWORD));
ESP_ERROR_CHECK_WITHOUT_ABORT(wifi_service_set_sta_info(wifi_serv, &wifi_config));
esp_restart();
return ESP_OK;
}
if (wifi_serv_stat == WIFI_SERV_EVENT_CONNECTED && reconnect == false)
return ESP_OK;
if ((wifi_serv_stat == WIFI_SERV_EVENT_CONNECTED && reconnect ))
{
memset(wifi_config.sta.ssid,0,sizeof(wifi_config.sta.ssid));
memcpy(wifi_config.sta.ssid ,hd_param.WIFI_SSID,sizeof(hd_param.WIFI_SSID));
memset(wifi_config.sta.password,0,sizeof(wifi_config.sta.password));
memcpy(wifi_config.sta.password ,hd_param.WIFI_PASSWORD,sizeof(hd_param.WIFI_PASSWORD));
ESP_ERROR_CHECK_WITHOUT_ABORT(wifi_service_disconnect(wifi_serv));
//ESP_ERROR_CHECK_WITHOUT_ABORT(wifi_service_erase_ssid_manager_info(wifi_serv));
ESP_ERROR_CHECK_WITHOUT_ABORT(wifi_service_set_sta_info(wifi_serv, &wifi_config));
vTaskDelay(200/portTICK_PERIOD_MS);
esp_restart();
//ESP_ERROR_CHECK_WITHOUT_ABORT(wifi_service_connect(wifi_serv));
return ESP_OK;
}
if (is_smart_config) //处于EspTotch配网中不能再自动连接了
{
return ESP_OK;
}
if (s_retry_num < 3) { //尝试3次连接
if (wifi_serv_stat == WIFI_SERV_EVENT_UNKNOWN || wifi_serv_stat == WIFI_SERV_EVENT_DISCONNECTED || reconnect)
{
wifi_service_get_last_ssid_cfg(wifi_serv,&wifi_config);
ESP_LOGI(TAG_WIFI, "old wifi SSID:%s, password:%s",wifi_config.sta.ssid, wifi_config.sta.password);
ESP_LOGI(TAG_WIFI, "retry %d to connect to the AP SSID:%s, password:%s",s_retry_num,hd_param.WIFI_SSID, hd_param.WIFI_PASSWORD);
memset(wifi_config.sta.ssid,0,sizeof(wifi_config.sta.ssid));
memcpy(wifi_config.sta.ssid ,hd_param.WIFI_SSID,sizeof(hd_param.WIFI_SSID));
memset(wifi_config.sta.password,0,sizeof(wifi_config.sta.password));
memcpy(wifi_config.sta.password ,hd_param.WIFI_PASSWORD,sizeof(hd_param.WIFI_PASSWORD));
ESP_LOGI(TAG_WIFI, "wifi_config SSID:%s, password:%s",wifi_config.sta.ssid, wifi_config.sta.password);
//由于手机EspTouch配网一直不成功增加了WIFI_IS_SMART_CONFIG =1配网,2直连 通过串口配置ssid,password
if (hd_param.WIFI_IS_SMART_CONFIG == 1){
ESP_ERROR_CHECK_WITHOUT_ABORT(wifi_service_setting_start(wifi_serv,0));
is_smart_config = true;
} else{
ESP_ERROR_CHECK_WITHOUT_ABORT(wifi_service_set_sta_info(wifi_serv, &wifi_config));
ESP_ERROR_CHECK_WITHOUT_ABORT(wifi_service_connect(wifi_serv));
is_smart_config = false;
}
//语音:30 WiFi连接中
player_mp3_play((uint16_t)voice_wifi_connecting);
s_retry_num++;
//esp_restart();
}
} else { //3次后 就开始配网
if (!is_smart_config){
//语音 29 WIFI未连接,请用手机或串口配置
player_mp3_play((uint16_t)voice_wifi_disconnected);
wifi_service_setting_start(wifi_serv,0);
s_retry_num = 0;
is_smart_config = true;
}
}
return ESP_OK;
}
static esp_err_t wifi_service_cb(periph_service_handle_t handle, periph_service_event_t *evt, void *ctx)
{
wifi_config_t wifi_cfg;
if (evt->type == WIFI_SERV_EVENT_CONNECTED) {
wifi_serv_stat = WIFI_SERV_EVENT_CONNECTED;
ESP_LOGI(TAG_WIFI, "PERIPH_WIFI_CONNECTED [%d]", __LINE__);
if (is_smart_config){
wifi_service_setting_stop(wifi_serv,0);
is_smart_config = false;
}
if( wifi_service_get_last_ssid_cfg(wifi_serv,&wifi_cfg) == ESP_OK )
{
if (memcmp(hd_param.WIFI_SSID,wifi_cfg.sta.ssid,32) != 0 || memcmp(hd_param.WIFI_PASSWORD,wifi_cfg.sta.password,64) != 0)
{
bzero(hd_param.WIFI_SSID,sizeof(hd_param.WIFI_SSID));
bzero(hd_param.WIFI_PASSWORD,sizeof(hd_param.WIFI_PASSWORD));
strcpy((char *)hd_param.WIFI_SSID,(char *)wifi_cfg.sta.ssid);
strcpy((char *)hd_param.WIFI_PASSWORD,(char *)wifi_cfg.sta.password);
save_param();
}
hd_param.WIFI_IS_SMART_CONFIG = 2;
tcpip_adapter_ip_info_t ip;
tcpip_adapter_get_ip_info(TCPIP_ADAPTER_IF_STA, &ip);
memcpy(hd_param.WIFI_IP,((uint8_t*)(&ip.ip.addr)),4);
memcpy(hd_param.WIFI_GW,((uint8_t*)(&ip.gw.addr)),4);
memcpy(hd_param.WIFI_MASK,((uint8_t*)(&ip.netmask.addr)),4);
//语音:当前ip是
player_mp3_play((uint16_t)voice_current_ip);
vTaskDelay(200);
char ipstr[20];
sprintf(ipstr,"%d.%d.%d.%d",hd_param.WIFI_IP[0],hd_param.WIFI_IP[1],hd_param.WIFI_IP[2],hd_param.WIFI_IP[3]);
int j= strlen((char *)ipstr);
ESP_LOGI(TAG_WIFI, "WIFI_CONNECTED [%d],ip:%s,strlen:%d", __LINE__,ipstr,j);
for (int i=0;i< j;i++){
switch (ipstr)
{
case 46:
player_mp3_play((uint16_t)voice_point);
break;
case 48:
player_mp3_play((uint16_t)voice_zero);
break;
case 49:
player_mp3_play((uint16_t)voice_one);
break;
case 50:
player_mp3_play((uint16_t)voice_two);
break;
case 51:
player_mp3_play((uint16_t)voice_three);
break;
case 52:
player_mp3_play((uint16_t)voice_four);
break;
case 53:
player_mp3_play((uint16_t)voice_five);
break;
case 54:
player_mp3_play((uint16_t)voice_six);
break;
case 55:
player_mp3_play((uint16_t)voice_seven);
break;
case 56:
player_mp3_play((uint16_t)voice_eight);
break;
case 57:
player_mp3_play((uint16_t)voice_nine);
break;
default:
break;
}
vTaskDelay(60);
}
hd_param.WIFI_CONNECTED = true;
}
} else if (evt->type == WIFI_SERV_EVENT_DISCONNECTED) {
wifi_serv_stat = WIFI_SERV_EVENT_DISCONNECTED;
player_mp3_play((uint16_t)voice_wifi_disconnected);
ESP_LOGI(TAG_WIFI, "PERIPH_WIFI_DISCONNECTED [%d]", __LINE__);
hd_param.WIFI_CONNECTED = false;
wifi_service_disconnect_reason_t wifi_rs = wifi_service_disconnect_reason_get(wifi_serv);
if ((wifi_rs == WIFI_SERV_STA_AUTH_ERROR || wifi_rs == WIFI_SERV_STA_AP_NOT_FOUND) )
{
//语音 29 WIFI未连接,请用手机或串口配置
player_mp3_play((uint16_t)voice_wifi_disconnected);
}
} else if (evt->type == WIFI_SERV_EVENT_SETTING_TIMEOUT) {
wifi_serv_stat = WIFI_SERV_EVENT_SETTING_TIMEOUT;
ESP_LOGW(TAG_WIFI, "WIFI_SERV_EVENT_SETTING_TIMEOUT [%d]", __LINE__);
//语音 29 WIFI未连接,请用手机或串口配置
if (is_smart_config) //继续
{
// wifi_service_disconnect(wifi_serv);
// wifi_service_erase_ssid_manager_info(wifi_serv);
wifi_service_setting_start(wifi_serv,0);
s_retry_num = 0;
is_smart_config = true;
}
} else if (evt->type == WIFI_SERV_EVENT_SETTING_FINISHED){
ESP_LOGW(TAG_WIFI, "WIFI_SERV_EVENT_SETTING_FINISHED [%d]", __LINE__);
// is_smart_config = false;
} else if (evt->type == WIFI_SERV_EVENT_SETTING_FAILED ){
ESP_LOGW(TAG_WIFI, "WIFI_SERV_EVENT_SETTING_FAILED [%d]", __LINE__);
} else if (evt->type == WIFI_SERV_EVENT_CONNECTING){
ESP_LOGW(TAG_WIFI, "WIFI_SERV_EVENT_CONNECTING [%d]", __LINE__);
}
return ESP_OK;
}
void initialise_wifi_sta(void)
{
int reg_idx = 0;
wifi_service_config_t cfg = WIFI_SERVICE_DEFAULT_CONFIG();
cfg.evt_cb = wifi_service_cb;
cfg.setting_timeout_s = 300;
cfg.max_retry_time = 2;
wifi_serv = wifi_service_create(&cfg);
smart_config_info_t info = SMART_CONFIG_INFO_DEFAULT();
esp_wifi_setting_handle_t h = smart_config_create(&info);
esp_wifi_setting_regitster_notify_handle(h, (void *)wifi_serv);
wifi_service_register_setting_handle(wifi_serv, h, ®_idx);
ESP_ERROR_CHECK(wifi_connecting(false));
}
void monitor_even_task(void *pvParameters)
{
int wifi_reconnect_count =0;
int mqtt_heart_count =0; //60*15
uint8_t input[6]={0,0,0,0,0,0};
int initial_delay_count =0;
bool mqtt_initial = false;
while (1)
{
if (hd_param.WIFI_CONNECTED )
{
//开始其它网络连接成功后的任务
} else{
//
//语音提示wifi连接失败
//连接wifi
wifi_reconnect_count ++;
if (wifi_reconnect_count>10*5){ //5秒
wifi_connecting(false);
wifi_reconnect_count = 0;
}
}
vTaskDelay(200/portTICK_PERIOD_MS);//延时200ms
}
vTaskDelete(NULL);
}
void app_main(void)
{
// Initialize NVS
esp_log_level_set("*", ESP_LOG_INFO);
media_lib_add_default_adapter();
esp_err_t err = nvs_flash_init();
if (err == ESP_ERR_NVS_NO_FREE_PAGES || err == ESP_ERR_NVS_NEW_VERSION_FOUND) {
// NVS partition was truncated and needs to be erased
// Retry nvs_flash_init
ESP_ERROR_CHECK(nvs_flash_erase());
err = nvs_flash_init();
}
ESP_ERROR_CHECK( err );
ESP_ERROR_CHECK(esp_netif_init());
if (read_param() == ESP_ERR_NVS_NOT_FOUND)
set_param_default();
ESP_LOGI(TAG, "[1.11] Start codec chip");
board_handle = audio_board_init();
//es8388_config_adc_input(AUDIO_HAL_ADC_INPUT_LINE2);
audio_hal_ctrl_codec(board_handle->audio_hal, AUDIO_HAL_CODEC_MODE_BOTH, AUDIO_HAL_CTRL_START);
audio_hal_set_volume(board_handle->audio_hal,65);
initialise_uart();
initialise_mp3();// 提示语音
initialise_wifi_sta();
xTaskCreate(monitor_even_task,"monitor_even_task",1024*3,NULL, Priority_monitor, NULL);
}
输出日志
I (417) psram: This chip is ESP32-D0WD
I (419) spiram: Found 64MBit SPI RAM device
I (419) spiram: SPI RAM mode: flash 40m sram 40m
I (421) spiram: PSRAM initialized, cache is in low/high (2-core) mode.
I (428) cpu_start: Pro cpu up.
I (432) cpu_start: Starting app cpu, entry point is 0x40081668
0x40081668: call_start_cpu1 at C:/Espressif/frameworks/esp-idf-v4.4/components/esp_system/port/cpu_start.c:156
I (0) cpu_start: App cpu up.
I (1325) spiram: SPI SRAM memory test OK
I (1333) cpu_start: Pro cpu start user code
I (1333) cpu_start: cpu freq: 160000000
I (1334) cpu_start: Application information:
I (1337) cpu_start: Project name: zmgccs
I (1341) cpu_start: App version: 1
I (1346) cpu_start: Compile time: May 17 2022 09:57:15
I (1352) cpu_start: ELF file SHA256: 96a75952a694d25f...
I (1358) cpu_start: ESP-IDF: v4.4-dirty
I (1364) heap_init: Initializing. RAM available for dynamic allocation:
I (1371) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM
I (1377) heap_init: At 3FFB5390 len 0002AC70 (171 KiB): DRAM
I (1383) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM
I (1390) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM
I (1396) heap_init: At 4009BE6C len 00004194 (16 KiB): IRAM
I (1403) spiram: Adding pool of 4084K of external SPI memory to heap allocator
I (1411) spi_flash: detected chip: generic
I (1415) spi_flash: flash io: qio
I (1421) cpu_start: Starting scheduler on PRO CPU.
I (0) cpu_start: Starting scheduler on APP CPU.
I (1430) spiram: Reserving pool of 18K of internal memory for DMA/internal allocations
I (1500) zmgccs: [1.11] Start codec chip
I (1500) MY_BOARD_V1_0: i2c port sda_io:GPIO18 ,scl_io:GPIO23
W (1510) MYES8388_DRIVER: Warning: volume < -96! or > 0!
I (1510) MYES8388_DRIVER: init,out:00, in:00
I (1520) AUDIO_HAL: Codec moI (1530) gpio: GPIO[4]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0
I (1530) gpio: GPIO[13]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0
I (1530) gpio: GPIO[14]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0
I (1540) gpio: GPIO[15]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0
I (1550) gpio: GPIO[19]| InputEn: 0| OutputEn: 1| OpenDrain: 0| Pullup: 0| Pulldown: 1| Intr:0
I (1560) gpio: GPIO[21]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1570) gpio: GPIO[22]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1580) gpio: GPIO[27]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1590) gpio: GPIO[32]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1600) gpio: GPIO[33]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1610) gpio: GPIO[34]| InputEn: 1| OutputEn: 0| OpenDrain: 0| Pullup: 1| Pulldown: 0| Intr:0
I (1620) ZMG-MP3: [1.10] audio pipeline set init set
I (1620) ZMG-MP3: [1.11] mount spiffs
I (1750) PERIPH_SPIFFS: Partition size: total: 956561, used: 250749
I (1750) ZMG-MP3: [1.0] Create pipeline_save
I (1750) ZMG-MP3: [1.1] Create http stream to read data
I (1750) ZMG-MP3: [1.2] Create fatfs stream to save file
I (1760) ZMG-MP3: [1.4] Register all elements to pipeline_save
I (1770) ZMG-MP3: [1.5] Link elements together http_stream-->fatfs_stream
I (1780) AUDIO_PIPELINE: link el->rb, el:0x3f803920, tag:http, rb:0x3f803bb8
I (1780) ZMG-MP3: [1.3] Create fatfs stream to read file
I (1790) ZMG-MP3: [1.6] Create i2s stream to write data to codec chip
I (1800) I2S: APLL expected frequency is 8192000 Hz, real frequency is 8191999 Hz
I (1800) I2S: DMA Malloc info, datalen=blocksize=1200, dma_buf_count=3
I (1810) I2S: DMA Malloc info, datalen=blocksize=1200, dma_buf_count=3
I (1820) I2S: I2S0, MCLK output by GPIO0
I (1820) ZMG-MP3: [1.7] Create mp3 decoder to decode mp3 file
I (1830) MP3_DECODER: MP3 init
I (1830) ZMG-MP3: [1.8] Register all elements to audio pipeline
I (1840) ZMG-MP3: [1.9] Link elements together flash-->spiffs-->mp3_decoder-->i2s_stream-->[codec_chip]
I (1850) AUDIO_PIPELINE: link el->rb, el:0x3f808c24, tag:spiffs, rb:0x3f8090a4
I (1860) AUDIO_PIPELINE: link el->rb, el:0x3f808f34, tag:mp3, rb:0x3f80b0e4
I (1860) ZMG-MP3: [ 4 ] Set up event listener
I (1870) ZMG-MP3: [4.1] Listening event from all elements of pipeline
I (1880) ZMG-MP3: [4.2] Listening event from peripherals
E (1880) DISPATCHER: exe first list: 0x0
I (1890) DISPATCHER: dispatcher_event_task is running...
I (1910) AUDIO_THREAD: The wifi_serv task allocate stack on external memory
I (1920) wifi:wifi driver task: 3ffcb080, prio:23, stack:3584, core=1
I (1920) system_api: Base MAC address is not set
I (1920) system_api: read default base MAC address from EFUSE
I (1930) wifi:wifi firmware version: 7679c42
I (1930) wifi:wifi certification version: v7.0
I (1930) wifi:config NVS flash: enabled
I (1940) wifi:config nano formating: disabled
I (1940) wifi:Init data frame dynamic rx buffer num: 32
I (1950) wifi:Init management frame dynamic rx buffer num: 32
I (1950) wifi:Init management short buffer num: 32
I (1960) wifi:Init static tx buffer num: 16
I (1960) wifi:Init tx cache buffer num: 32
I (1960) wifi:Init static rx buffer size: 1600
I (1970) wifi:Init static rx buffer num: 10
I (1970) wifi:Init dynamic rx buffer num: 32
I (1980) wifi_init: rx ba win: 6
I (1980) wifi_init: tcpip mbox: 32
I (1980) wifi_init: udp mbox: 64
I (1990) wifi_init: tcp mbox: 6
I (1990) wifi_init: tcp tx win: 5744
I (1990) wifi_init: tcp rx win: 5744
I (2000) wifi_init: tcp mss: 1440
I (2000) wifi_init: WiFi/LWIP prefer SPIRAM
I (2010) wifi_init: WiFi IRAM OP enabled
I (2010) wifi_init: WiFi RX IRAM OP enabled
I (2020) phy_init: phy_version 4670,719f9f6,Feb 18 2021,17:07:07
I (2120) wifi:mode : sta (c0:49:ef:31:50:b8)
I (2130) wifi:enable tsf
I (2140) zmg-WIFI: old wifi SSID:WIFI_, password:zmg8
I (2140) zmg-WIFI: retry 0 to connect to the AP SSID:WIFI_, password:zmg8
I (2140) zmg-WIFI: wifi_config SSID:WIFI_, password:zmg8
I (2150) WIFI_SERV: WIFI_SERV_CMD_SETTING_START,index:0
I (2150) ZMG-MP3: [mp3.0] mp3_filename: /spiffs/00030.mp3
I (2160) AUDIO_ELEMENT: [spiffs-0x3f808c24] Element task created
I (2170) AUDIO_THREAD: The mp3 task allocate stack on external memory
I (2170) AUDIO_ELEMENT: [mp3-0x3f808f34] Element task created
I (2180) AUDIO_ELEMENT: [i2s-0x3f808dbc] Element task created
I (2190) AUDIO_PIPELINE: Func:audio_pipeline_run, Line:359, MEM Total:4235183 Bytes, Inter:182407 Bytes, Dram:167771 Bytes
I (2200) AUDIO_ELEMENT: [spiffs] AEL_MSG_CMD_RESUME,state:1
I (2210) smartconfig: SC version: V3.0.1
I (2220) SPIFFS_STREAM: File size is 2664 byte, pos:0
W (2240) SPIFFS_STREAM: No more data, ret:0
I (2240) AUDIO_ELEMENT: IN-[spiffs] AEL_IO_DONE,0
I (2240) AUDIO_ELEMENT: [mp3] AEL_MSG_CMD_RESUME,state:1
I (2240) MP3_DECODER: MP3 opened
I (2260) I2S: APLL expected frequency is 8192000 Hz, real frequency is 8191999 Hz
I (2260) I2S: DMA Malloc info, datalen=blocksize=600, dma_buf_count=3
I (2260) I2S: DMA Malloc info, datalen=blocksize=600, dma_buf_count=3
I (2270) ZMG-MP3: [ * ] set i2s rates=16000, bits=16, ch=1 ok
I (2280) AUDIO_ELEMENT: [i2s] AEL_MSG_CMD_RESUME,state:1
I (2280) I2S_STREAM: AUDIO_STREAM_WRITER
I (2290) AUDIO_PIPELINE: Pipeline started
I (2290) zmg-MQTT: MQTT line:364,Task = 1612
I (2400) AUDIO_ELEMENT: IN-[mp3] AEL_IO_DONE,-2
I (3490) MP3_DECODER: Closed
I (3620) AUDIO_ELEMENT: IN-[i2s] AEL_IO_DONE,-2
W (3840) ZMG-MP3: [ * ] music play Stop
I (6310) wifi:ic_enable_sniffer
I (6310) smartconfig: Start to find channel...
I (6310) SMART_CONFIG: SC_EVENT_SCAN_DONE
W (302210) WIFI_SERV: STATE type:4, pdata:0x0, len:0
I (302210) WIFI_SERV: WIFI_SERV_EVENT_SETTING_TIMEOUT
I (302210) wifi:ic_disable_sniffer
W (302220) zmg-WIFI: WIFI_SERV_EVENT_SETTING_TIMEOUT [246]
I (302230) WIFI_SERV: Connect to wifi ssid: WIFI_, pwd: zmg8 此处故意设置了错误的ssid和错误的密码然后进入配网状态
I (302230) WIFI_SERV: WIFI_SERV_CMD_SETTING_START,index:0
I (302290) smartconfig: SC version: V3.0.1
I (306390) wifi:ic_enable_sniffer
I (306390) smartconfig: Start to find channel... 此后无法发现手机的配网信息
I (306390) SMART_CONFIG: SC_EVENT_SCAN_DONE
I (306390) SMART_CONFIG: SC_EVENT_SCAN_DONE
W (602290) WIFI_SERV: STATE type:4, pdata:0x0, len:0
I (602290) WIFI_SERV: WIFI_SERV_EVENT_SETTING_TIMEOUT
I (602290) wifi:ic_disable_sniffer
W (602300) zmg-WIFI: WIFI_SERV_EVENT_SETTING_TIMEOUT [246]
I (602300) WIFI_SERV: Connect to wifi ssid: WIFI_, pwd: zmg8
I (602310) WIFI_SERV: WIFI_SERV_CMD_SETTING_START,index:0
I (602360) smartconfig: SC version: V3.0.1
I (606460) wifi:ic_enable_sniffer
I (606460) smartconfig: Start to find channel...
I (606460) SMART_CONFIG: SC_EVENT_SCAN_DONE
I (606460) SMART_CONFIG: SC_EVENT_SCAN_DONE
I (606460) SMART_CONFIG: SC_EVENT_SCAN_DONE
求助:使用esp-adf下面的smart config模式使用EspTouch配网一点反应都没有。
-
- Posts: 184
- Joined: Fri Dec 15, 2017 2:45 am
Re: 求助:使用esp-adf下面的smart config模式使用EspTouch配网一点反应都没有。
你使用的是哪个例程, 例程测试好像没问题啊
Re: 求助:使用esp-adf下面的smart config模式使用EspTouch配网一点反应都没有。
找到使用 esptouch和airkiss配网失败的问题了:
esp-adf2.4下的配网例子都是有问题的。
esp-idf4.4/examples/wifi/smart_config的配网例子可以使用但是有手机收不到回应的问题,
需修改idf4.4目录下的smartconfig_ack.c第124行的代码
if (setsockopt(send_sock, SOL_SOCKET, SO_BROADCAST | SO_REUSEADDR, &optval, sizeof(int)) < 0) {
ESP_LOGE(TAG, "setsockopt failed");
goto _end;
}
修改为
if (setsockopt(send_sock, SOL_SOCKET, SO_BROADCAST , &optval, sizeof(int)) < 0) {
ESP_LOGE(TAG, "setsockopt SO_BROADCAST failed");
goto _end;
}
if (setsockopt(send_sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int)) < 0) {
ESP_LOGE(TAG, "setsockopt SO_REUSEADDR failed");
goto _end;
}
参考 https://github.com/espressif/esp-idf/co ... 77f130e1f9
esp-adf2.4下的配网例子都是有问题的。
esp-idf4.4/examples/wifi/smart_config的配网例子可以使用但是有手机收不到回应的问题,
需修改idf4.4目录下的smartconfig_ack.c第124行的代码
if (setsockopt(send_sock, SOL_SOCKET, SO_BROADCAST | SO_REUSEADDR, &optval, sizeof(int)) < 0) {
ESP_LOGE(TAG, "setsockopt failed");
goto _end;
}
修改为
if (setsockopt(send_sock, SOL_SOCKET, SO_BROADCAST , &optval, sizeof(int)) < 0) {
ESP_LOGE(TAG, "setsockopt SO_BROADCAST failed");
goto _end;
}
if (setsockopt(send_sock, SOL_SOCKET, SO_REUSEADDR, &optval, sizeof(int)) < 0) {
ESP_LOGE(TAG, "setsockopt SO_REUSEADDR failed");
goto _end;
}
参考 https://github.com/espressif/esp-idf/co ... 77f130e1f9
Who is online
Users browsing this forum: No registered users and 4 guests