1. 程式人生 > >【Alios-things筆記】alios-things esp32配網錯誤

【Alios-things筆記】alios-things esp32配網錯誤

錯誤日誌:

[37m<DEBUG> [aes_decrypt_string#88] : security level: 3[0m
[37m<DEBUG> [get_ssid_passwd_from_w#697] : ssid:YUNYIN, tlen:21
[0m
[37m<DEBUG> [zconfig_callback_channel_locked#1188] : channel lock @ 1
[0m
[020310]<V> IOTX_AWSS_LOCK_CHAN
[37m<DEBUG> [zconfig_callback_over#1249] : zconfig done. ssid:YUNYIN, mac:000000000000
[0m
[37m<DEBUG> [zconfig_got_ssid_passwd_callback#117] : ssid:YUNYIN, bssid:8cab8edd96c0, wpa2-psk, aes, 11
[0m
[020330]<V> IOTX_AWSS_GOT_SSID_PASSWD
I (21931) wifi: ic_disable_sniffer
I (21931) wifi: flush txq
I (21931) wifi: stop sw txq
I (21941) wifi: lmac stop hw txq
[37m<DEBUG> [aws_main_thread_func#414] : [channel scanning] 20370 ms
[0m
wifi_getset_ops 278: channe - 11
E (22081) wifi: esp_wifi_set_channel 1151 wifi not start or sniffer not enabled,         		should start wifi or enable sniffer first
ESP_ERROR_CHECK failed: esp_err_t 0x3002 at 0x4008996a
Backtrace: 0x4008807c:0x3fffb1d0 0x400883c9:0x3fffb1f0 0x4008996a:0x3fffb210 0x400899c9:0x3fffb290 0x400f9cc2:0x3fffb2b0 0x40115b93:0x3fffb2d0 0x40120dd1:0x3fffb2f0 0x40120fd8:0x3fffb310 0x4012121f:0x3fffb370 0x4011a64a:0x3fffb390 0x4011a1c3:0x3fffb440 0x40115ad7:0x3fffb4b0 0x40108c26:0x3fffb4d0 0x4010c669:0x3fffb4f0 0x4010c69a:0x3fffb510 0x401078fc:0x3fffb530 0x40085f3d:0x3fffb550

出現該錯誤的原因是在模組獲取都WIFI的名字和密碼後會關閉WIFI的混雜模式,此時如果模組的通道與要連線的WIFI通道不一樣就會呼叫aws_try_adjust_chan函式切換通道,就會產生該錯誤。這是由於zconfig_got_ssid_passwd_callback函式和aws_main_thread_func函式中的aws_try_adjust_chan函式呼叫時機引起的。

解決方法: 在zconfig_got_ssid_passwd_callback函式中,將WIFI模組的通道設定成被連線的WIFI的通道

void zconfig_got_ssid_passwd_callback(u8 *ssid, u8 *passwd,
                                      u8 *bssid, u8 auth, u8 encry, u8 channel)
{
    ........
    aws_result_auth = auth;
    aws_result_encry = encry;
    aws_result_channel = channel;

	//切換通道
	if(aws_locked_chn !=aws_result_channel)
	{
		aws_set_dst_chan(aws_result_channel);
		aws_switch_channel();
	}
   ........
}