1. ESP-IDF v2.x 升级到 v3.x的一些有趣现象
1.1 AP模式下,在v3.x后,.ssid_len参数必须严格按照AP_SSID字符个数给出,不然会出现实际运行时SSID和软件配置不匹配情况,而在v2.x版本下,.ssid_len设置为0也运行正常。
wifi_config_t ap_config = {
.ap = {
.ssid = EXAMPLE_DEFAULT_AP_SSID,
.password = EXAMPLE_DEFAULT_AP_PWD,
.ssid_len = 7,
.max_connection = 1,
.authmode = WIFI_AUTH_WPA_WPA2_PSK
}
};
1.2 STA模式下,在v2.x版本时,当软件STA配置时设置了密码,而外界WIFI路由器在不设置密码情况下,ESP32依然可以连上外界WIFI,但是在v3.x版本时,这种情况不会出现,软件STA配置必须和外部WIFI路由器配置一致时,才可以连上。
2. 串口乱码问题
ESP32的信息打印串口需要接三条信号TXD、RXD、GND,现在大部分都是用USB转TTL接调试,若GND信号线没有可靠的连接到ESP32板子上,电脑上串口接收软件在某些情况下可能会出现接收到乱码情况,给问题排查带来不便。当然,不接GND信号大部分情况下电脑串口软件是接收不到任何信息的。
附上ESP32开机打印信息摘要如下:
ets Jun 8 2016 00:22:57
rst:0x1 (POWERON_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
ets Jun 8 2016 00:22:57
rst:0x10 (RTCWDT_RTC_RESET),boot:0x13 (SPI_FAST_FLASH_BOOT)
configsip: 0, SPIWP:0xee
clk_drv:0x00,q_drv:0x00,d_drv:0x00,cs0_drv:0x00,hd_drv:0x00,wp_drv:0x00
mode:DIO, clock div:2
load:0x3fff0018,len:4
load:0x3fff001c,len:6348
load:0x40078000,len:11308
ho 0 tail 12 room 4
load:0x40080400,len:6272
entry 0x4008073c
[0;32mI (31) boot: ESP-IDF v3.3-beta3-dirty 2nd stage bootloader[0m
[0;32mI (31) boot: compile time 11:57:58[0m
[0;32mI (31) boot: Enabling RNG early entropy source...[0m
[0;32mI (36) boot: SPI Speed : 40MHz[0m
[0;32mI (40) boot: SPI Mode : DIO[0m
[0;32mI (44) boot: SPI Flash Size : 4MB[0m
[0;32mI (48) boot: Partition Table:[0m
[0;32mI (52) boot: ## Label Usage Type ST Offset Length[0m
[0;32mI (59) boot: 0 nvs WiFi data 01 02 00009000 00004000[0m
[0;32mI (67) boot: 1 otadata OTA data 01 00 0000d000 00002000[0m
[0;32mI (74) boot: 2 phy_init RF data 01 01 0000f000 00001000[0m
[0;32mI (82) boot: 3 factory factory app 00 00 00010000 00100000[0m
[0;32mI (89) boot: 4 ota_0 OTA app 00 10 00110000 00100000[0m
[0;32mI (97) boot: 5 ota_1 OTA app 00 11 00210000 00100000[0m
[0;32mI (104) boot: End of partition table[0m
[0;32mI (108) esp_image: segment 0: paddr=0x00110020 vaddr=0x3f400020 size=0x1bca0 (113824) map[0m
[0;32mI (157) esp_image: segment 1: paddr=0x0012bcc8 vaddr=0x3ffb0000 size=0x03014 ( 12308) load[0m
[0;32mI (162) esp_image: segment 2: paddr=0x0012ece4 vaddr=0x40080000 size=0x00400 ( 1024) load[0m
[0;32mI (164) esp_image: segment 3: paddr=0x0012f0ec vaddr=0x40080400 size=0x00f24 ( 3876) load[0m
[0;32mI (174) esp_image: segment 4: paddr=0x00130018 vaddr=0x400d0018 size=0x6d88c (448652) map[0m
[0;32mI (339) esp_image: segment 5: paddr=0x0019d8ac vaddr=0x40081324 size=0x0ee2c ( 60972) load[0m
[0;32mI (374) boot: Loaded app from partition at offset 0x110000[0m
[0;32mI (374) boot: Disabling RNG early entropy source...[0m
[0;32mI (375) cpu_start: Pro cpu up.[0m
[0;32mI (378) cpu_start: Application information:[0m
[0;32mI (383) cpu_start: Project name: waw[0m
[0;32mI (388) cpu_start: App version: 1[0m
[0;32mI (392) cpu_start: Compile time: Jun 13 2019 11:58:12[0m
[0;32mI (398) cpu_start: ELF file SHA256: 47a4891939ad6350...[0m
[0;32mI (404) cpu_start: ESP-IDF: v3.3-beta3-dirty[0m
[0;32mI (410) cpu_start: Starting app cpu, entry point is 0x400810c8[0m
[0;32mI (0) cpu_start: App cpu up.[0m
[0;32mI (420) heap_init: Initializing. RAM available for dynamic allocation:[0m
[0;32mI (427) heap_init: At 3FFAE6E0 len 00001920 (6 KiB): DRAM[0m
[0;32mI (433) heap_init: At 3FFB9DC0 len 00026240 (152 KiB): DRAM[0m
[0;32mI (439) heap_init: At 3FFE0440 len 00003AE0 (14 KiB): D/IRAM[0m
[0;32mI (446) heap_init: At 3FFE4350 len 0001BCB0 (111 KiB): D/IRAM[0m
[0;32mI (452) heap_init: At 40090150 len 0000FEB0 (63 KiB): IRAM[0m
[0;32mI (458) cpu_start: Pro cpu start user code[0m
[0;32mI (141) cpu_start: Starting scheduler on PRO CPU.[0m
[0;32mI (0) cpu_start: Starting scheduler on APP CPU.[0m
[0;32mI (204) NVS_Storage:: test sys ota config Succeed Read nUpdateAckCount= 22 nOTAStatus = 0[0m
I (214) wifi: wifi driver task: 3ffc15b0, prio:23, stack:3584, core=0
I (214) wifi: wifi firmware version: 7240fb7
I (214) wifi: config NVS flash: enabled
I (214) wifi: config nano formating: disabled
[0;32mI (224) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE[0m
[0;32mI (234) system_api: Base MAC address is not set, read default base MAC address from BLK0 of EFUSE[0m
I (264) wifi: Init dynamic tx buffer num: 32
I (264) wifi: Init data frame dynamic rx buffer num: 32
I (264) wifi: Init management frame dynamic rx buffer num: 32
I (264) wifi: Init management short buffer num: 32
I (264) wifi: Init static rx buffer size: 1600
I (274) wifi: Init static rx buffer num: 10
I (274) wifi: Init dynamic rx buffer num: 32
[0;32mI (1354) phy: phy_version: 4100, 2a5dd04, Jan 23 2019, 21:00:07, 0, 0[0m
I (1354) wifi: mode : sta (30:ae:a4:00:1f:4c) + softAP (30:ae:a4:00:1f:4d)
I (1364) wifi: Total power save buffer number: 16
I (1364) wifi: Init max length of beacon: 752/752
I (1364) wifi: Init max length of beacon: 752/752
[0;32mI (1374) udp_server:: task udp_conn start.[0m
[0;32mI (1374) wifi_init:: event_handler:SYSTEM_EVENT_STA_START![0m
[0;32mI (1374) udp_client:: udp client ok[0m
[0;32mI (1384) wifi_init:: event_handler:SYSTEM_EVENT_AP_START![0m
[0;32mI (1374) Captdns:: CaptDNS inited![0m
[0;32mI (1394) tcp_client:: tcp_client will start after 20s...[0m
[0;32mI (1394) web_server:: tcp_server will start after 1.5s...[0m
[0;32mI (1394) udp_server:: sta has connected to ap.[0m
[0;32mI (1414) udp_server:: create udp server after 3s...[0m
I (2874) wifi: ap channel adjust o:1,1 n:10,2
I (2884) wifi: new:<10,2>, old:<1,0>, ap:<10,2>, sta:<10,2>, prof:1
I (2884) wifi: state: init -> auth (b0)
I (2884) wifi: state: auth -> assoc (0)
I (2894) wifi: state: assoc -> run (10)
I (2894) wifi: connected with 31253, channel 10, bssid = c8:3a:35:07:ed:f8
I (2894) wifi: pm start, type: 1
[0;32mI (2904) wifi_init:: event_handler:SYSTEM_EVENT_STA_CONNECTED![0m
[0;32mI (2914) web_server:: create_tcp_server.[0m
[0;32mI (2914) web_server:: server socket....port=80[0m
[0;32mI (2914) web_server:: tcp connection established![0m
I (3074) wifi: ampdu: ignore deleting tx BA0
[0;32mI (3704) event: sta ip: 192.168.43.6, mask: 255.255.255.0, gw: 192.168.43.1[0m
[0;32mI (3704) wifi_init:: event_handler:SYSTEM_EVENT_STA_GOT_IP![0m
[0;32mI (3704) wifi_init:: got ip:192.168.43.6[0m
[0;32mI (4424) udp_server:: create_udp_server.[0m
[0;32mI (4424) wifi_init:: create_udp_server() port:16001[0m
[0;32mI (4424) udp_server:: task send_recv_data start![0m
[0;32mI (11404) tcp_client:: create_tcp_client.[0m
[0;32mI (21404) tcp_client:: connecting to ONENET server...[0m
[0;32mI (21444) tcp_client:: connect to ONENET server success![0m
3. WIFI 信道现象
ESP32工作在AP+STA模式时,AP的信道设置无效,AP的信道强制和STA连接上的路由器信道一致,并跟随其改变而改变。