连接WiFi
01 设置模式 STA
命令: AT+WMODE=<MODE>,<save_flash>
参数1:<MODE>
Wi-Fi工作模式(0:未初始化或者关闭Wi-Fi 1:STA 2:AP 3:AP+STA)
参数2:<save_flash>
是否保存到flash(0:不保存 1:保存)
AT+WMODE=1,0
WIFI is already running[AI_FAtWMode()-117]wifi start success
OK
[MEM] After do cmd, available heap 160064
02 查找WiFi
AT+WSCAN
+WSCAN:index SSID,CH,SECURITY,RSSI,BSSID
1 wenhou,1,WPA/WPA2 AES,-42,a4:1a:3a:5d:56:08
2 ,1,WPA/WPA2 AES,-44,a6:1a:3a:2d:56:08
3 wh5,153,WPA/WPA2 AES,-48,a4:1a:3a:5d:56:0a
4 ,153,WPA/WPA2 AES,-48,a6:1a:3a:5d:56:08
OK
[MEM] After do cmd, available heap 160064
03 连接WiFi
命令: AT+WJAP=<ssid>,<pwd>[,<bssid>]
参数1:<ssid>
连接的AP的SSID(最大长度为32字节)
参数2:<pwd>
连接的AP的密码(最大长度为32字节)
参数3:<bssid>
连接的AP的BSSID(一般不用)
AT+WJAP=wenhou,password
[AI_FAtWJAP()-598]Connect to wenhou
RTL8721D[Driver]: set ssid [wenhou]
RTL8721D[Driver]: rtw_set_wpa_ie[1160]: AuthKeyMgmt = 0x2
RTL8721D[Driver]: rtw_restruct_sec_ie[4279]: no pmksa cached
RTL8721D[Driver]: start auth to a4:1a:3a:5d:56:08
RTL8721D[Driver]: auth alg = 2
RTL8721D[Driver]:
OnAuthClient:algthm = 0, seq = 2, status = 0, sae_msg_len = 0
RTL8721D[Driver]: auth success, start assoc
RTL8721D[Driver]: association success(res=3)
RTL8721D[Driver]: ClientSendEAPOL[1650]: no use cache pmksa
RTL8721D[Driver]: set pairwise key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4)
RTL8721D[Driver]: set group key to hw: alg:4(WEP40-1 WEP104-5 TKIP-2 AES-4) keyid:2
[AI_WifiReConnectCallbak()-756](220)wenhou
+EVENT:WIFI_CONNECT
+EVENT:WIFI_GOT_IP
[AI_SocketTTAutoRunThread()-4027]socket auto TT not set
Interface 0 IP address : 192.168.1.100
OK
[MEM] After do cmd, available heap 152032
04 AT+WAUTOCONN 上电自动重连Wi-Fi
命令: AT+WAUTOCONN=<status>
参数1:<status>
0:禁用 1:使能
这四个AT指令挨个填写,就可以实现自动连接WIFI操作