Wi-Fi AT Commands
Note
The Wi-Fi AT commands are enabled by default and cannot be disabled.
Wi-Fi AT Error Codes
The error codes for Wi-Fi AT commands are defined as follows:
Error Code |
Description |
---|---|
1 |
Required parameters not provided |
2 |
Invalid parameter value |
3 |
Parameters number error |
4 |
Insufficient memory |
5 |
Function not support |
6 |
Unknown error |
7 ~ 16 |
Reserved |
17 |
Connect error |
18 |
Result retrieval failed |
19 |
Invalid Wi-Fi state |
20 |
Invalid scan parameters |
21 |
AP start failed |
22 |
AP start timeout |
AT+WLCONN
Description
Connect to a router (STA mode)
Command Format
AT+WLCONN=[<type>,<value>,<type>,<value>……]
Response Format
Successful Response:
OK
Error Response: definitions of error_no are in Wi-Fi AT Error Codes.
ERROR: <error_no>
AT Messages
When the connection process is complete, a message indicating success or failure will be displayed:
[$]wifi connected
[$]wifi connect failed
When an IPv4 address is obtained, there will be relevant prompt messages indicating success or timeout:
[$]wifi got ip:"<ip>"
[$]wifi got ip timeout
When disconnected from the router, a disconnection prompt message will be displayed:
[$]wifi disconnected
Parameters
<type>: Parameter type, followed by corresponding <value>
ssid
: followed by SSID namebssid
: followed by BSSID addressch
: followed by channel numberpw
: followed by connection passwordkey_id
: followed by WEP key ID
<value>: Specific parameter corresponding to <type>
<ssid>: Wi-Fi SSID name
Maximum length: 32 characters
<bssid>: MAC address of the AP
Format: Colon-separated hexadecimal (e.g., 1a:2b:3c:4d:5e:6f)
<ch>: Wireless channel
Default value: 0 (auto-select)
<pw>: Wi-Fi connection password
<key_id>: Key index for WEP encryption mode
Valid range: [0,3]
Note
Parameters like <ssid>, <bssid>, <ch>, etc., can be arranged in any order
Examples
Connect to a router with SSID MyWiFi
and password password123
:
AT+WLCONN=ssid,MyWiFi,pw,password123
OK
Connect to a router with BSSID 1a:2b:3c:4d:5e:6f
and password securepass
:
AT+WLCONN=bssid,1a:2b:3c:4d:5e:6f,pw,securepass
OK
AT+WLDISCONN
Description
Disconnect from the current Wi-Fi connection (STA mode)
Command Format
AT+WLDISCONN
Response Format
Successful Response:
OK
Error Response: definitions of error_no are in Wi-Fi AT Error Codes.
ERROR: <error_no>
AT+WLSTATICIP
Description
Configure static IP address for STA mode
Command Format
AT+WLSTATICIP=<ip>[,<gateway>,<netmask>]
Response Format
Successful Response:
OK
Error Response: definitions of error_no are in Wi-Fi AT Error Codes.
ERROR: <error_no>
Parameters
- <ip>: IPv4 address
Format: IPv4 address string (e.g., 192.168.1.100)
- <gateway>: Gateway address
Default value: Automatically calculated based on IP
- <netmask>: Subnet mask
Default value: 255.255.255.0
AT+WLSCAN
Description
Scan for nearby Wi-Fi networks
Command Format
AT+WLSCAN=[<type>,<value>,<type>,<value>]
Response Format
Scan results:
<index>, <MAC address>, <signal strength>, <channel>, <mode>, <encryption type>, <SSID>
...
OK
Error Response: definitions of error_no are in Wi-Fi AT Error Codes.
ERROR: <error_no>
Parameters
- <type>: Scan filter type
ssid
: followed by SSID namech
: followed by channel list
- <value>: Specific parameter corresponding to <type>
<ssid>: Target SSID name
<chlist>: Channel list (e.g., 1:6:11)
Note
Parameters like <ssid>, <ch>, etc., can be arranged in any order
If <ch> parameter is not specified, all available channels will be scanned
Example
Scan for all routers on channels 1, 6, and 11:
AT+WLSCAN=ch,1:6:11
1, a4:1a:3a:0d:0f:35, -26, 1, AX, "Open", "TP-LINK_0F35"
2, a6:1a:3a:7d:0f:35, -26, 1, AX, "WPA/WPA2 AES", ""
3, 78:60:5b:0f:b1:d7, -34, 6, AX, "WPA/WPA2 AES", "TP-LINK_B1D7"
4, 04:79:75:8e:3c:d5, -42, 11, AX, "WPA2/WPA3-SAE AES", "huaweipro4"
OK
AT+WLRSSI
Description
Get the signal strength of the currently connected AP
Command Format
AT+WLRSSI
Response Format
RSSI = <current signal strength>
DATA_RSSI = <data signal strength>
BEACON_RSSI = <beacon signal strength>
OK
Note
Signal strength obtained when not connected to a router has no practical significance
AT+WLSTARTAP
Description
Enable AP mode
Command Format
AT+WLSTARTAP=[<type>,<value>,<type>,<value>……]
Response Format
Successful Response:
OK
Error Response: definitions of error_no are in Wi-Fi AT Error Codes.
ERROR: <error_no>
AT Messages
When a STA actively connects or disconnects, the following prompt messages will appear:
[$]client connected:"<sta_mac>"
[$]client disconnected:"<sta_mac>"
When an IPv4 address is successfully assigned to a STA, the following prompt message will appear:
[$]assign client ip:"<sta_ip>",hwaddr:"<sta_mac>"
Parameters
- <type>: Parameter type
ssid
: followed by SSID namech
: followed by channel numberpw
: followed by connection passwordsec
: followed by encryption type
<value>: Specific parameter corresponding to <type>
- <sec>: Security mode
Available values: open/wep/wpa2/wpa3
- <ch>: AP channel
Valid range: [1,11]
Default value: 1
Note
Parameters like <ssid>, <ch>, <pw>, etc., can be arranged in any order
Examples
Start an Open AP with SSID MyAP
on channel 6:
AT+WLSTARTAP=ssid,MyAP,ch,6,sec,open
OK
Start a WPA2 encrypted AP with SSID SecureAP
and password password123
on default channel 1:
AT+WLSTARTAP=sec,wpa2,pw,password123,ssid,SecureAP
OK
AT+WLSTOPAP
Description
Disable AP mode
Command Format
AT+WLSTOPAP
Response Format
Successful Response:
OK
Parameters
None
AT+WLSTATE
Description
Query Wi-Fi status information
Command Format
AT+WLSTATE
Response Format
WLAN0 Status: Running
==============================
max_skbinfo_used_num=<historical maximum number of skbinfo used>, skbinfo_used_num=<current number of skbinfo used>
max_skbdata_used_num=<historical maximum number of skbdata used>, skbdata_used_num=<current number of skbdata used>
WLAN0 Setting:
==============================
MODE => <mode: STATION or AP>
SSID => <ssid>
BSSID => <bssid>
CHANNEL => <channel>
SECURITY => <security mode: OPEN, WPA2, WPA3, or various mixed encryptions>
PASSWORD => <password>
Interface (0)
==============================
MAC => <local mac address>
IP => <local IPv4 address>
GW => <local gateway address>
MSK => <local subnet mask>
WLAN1 Status: Running
==============================
WLAN1 Setting:
==============================
MODE => <mode: STATION or AP>
SSID => <ssid>
BSSID => <bssid>
CHANNEL => <channel>
SECURITY => <security mode: OPEN, WPA2, WPA3, or various mixed encryptions>
PASSWORD => <password>
Interface (1)
==============================
MAC => <local mac address>
IP => <local IPv4 address>
GW => <local gateway address>
MSK => <local subnet mask>
Associated Client List:
==============================
Client Num: <number of currently connected STAs>
Client 1:
IPv4 address: <ip address of STA 1>, MAC address: <mac address of STA 1>, rssi: <signal strength of STA 1>
Client 2:
IPv4 address: <ip address of STA 2>, MAC address: <mac address of STA 2>, rssi: <signal strength of STA 2>
...
OK
Example
Get current Wi-Fi status information
AT+WLSTATE
WLAN0 Status: Running
==============================
max_skbbuff_used_num=8, skbbuff_used_num=4
WLAN0 Setting:
==============================
MODE => STATION
SSID => mowifi
BSSID => e8:91:20:fa:8d:1d
CHANNEL => 10
SECURITY => WPA2 AES
PASSWORD => 12345678
Interface (0)
==============================
MAC => 00:e0:4c:b7:23:12
IP => 192.168.55.206
GW => 192.168.55.1
MSK => 255.255.255.0
WLAN1 Status: Running
==============================
WLAN1 Setting:
==============================
MODE => AP
SSID => test
BSSID => 00:e1:4c:b7:23:12
CHANNEL => 10
SECURITY => OPEN
PASSWORD =>
Interface (1)
==============================
MAC => 00:e1:4c:b7:23:12
IP => 192.168.43.1
GW => 192.168.43.1
MSK => 255.255.255.0
Associated Client List:
==============================
Client Num: 1
Client 1:
IPv4 address: 192.168.43.101, MAC address: ae:a8:7f:ca:18:7b, RSSI: -48
OK
AT+WLRECONN
Description
Configure automatic or fast reconnection strategy
Auto-reconnection attempts to reconnect to the router if the connection is lost for some reason after connecting to the router.
Fast reconnection saves SSID and password information to flash after connecting to the router, allowing automatic connection to the router without executing the AT+WLCONN command after restarting or powering on again.
Note
Both auto-reconnection and fast reconnection are enabled by default
Command Format
AT+WLRECONN=<mode>,<value>
Response Format
Successful Response:
OK
Error Response: definitions of error_no are in Wi-Fi AT Error Codes.
ERROR: <error_no>
AT Messages
When auto-reconnection is triggered, the following prompt messages will appear at the start and end of each reconnection attempt:
[$]wifi reconnecting
[$]wifi reconnect done
Parameters
<mode>: Reconnection mode
auto
: Auto reconnectfast
: Fast connect
<value>: Mode parameter
0: Disable this mode
1: Enable this mode
AT+WLPROMISC
Description
Enable/Disable Wi-Fi promiscuous mode
Command Format
AT+WLPROMISC=<enable>[,<all/apall>]
Response Format
Successful Response:
OK
Error Response: definitions of error_no are in Wi-Fi AT Error Codes.
ERROR: <error_no>
Parameters
- <enable>: Promiscuous mode switch
“enable”: Enable
“disable”: Disable
- <all/apall>: Packet filtering mode
“all”: Capture all packets
“apall”: Capture only AP-related packets
Note
When <enable> parameter is set to “enable”, <all/apall> parameter must be provided
AT+WLWPS
Description
Execute Wi-Fi WPS function
Command Format
AT+WLWPS=<pcb_pin>[,<pin_val>]
Response Format
Successful Response:
OK
Error Response: definitions of error_no are in Wi-Fi AT Error Codes.
ERROR: <error_no>
Parameters
- <pcb_pin>: WPS mode selection
“pcb”: Button mode
“pin”: PIN code mode
- <pin_val>: PIN code value
Must comply with verification rules
Must be provided when “pin” mode is selected
Note
<pin_val> parameter is only effective when <pcb_pin> is set to “pin”
AT+WLPS
Description
Configure Wi-Fi power-saving mode
LPS refers to the Wi-Fi power-saving mechanism when connected to a router.
IPS refers to the Wi-Fi power-saving mechanism when not connected to a router.
Note
Both LPS and IPS are enabled by default
Command Format
AT+WLPS=<mode>,<enable>[,<mode>,<enable>]
Response Format
Successful Response:
OK
Error Response: definitions of error_no are in Wi-Fi AT Error Codes.
ERROR: <error_no>
Parameters
- <mode>: Power-saving type, followed by corresponding <enable>
lps
: LPS power-saving mechanism, followed by switch valueips
: IPS power-saving mechanism, followed by switch value
- <enable>: Switch value
0: Disable
1: Enable
Note
<lps> and <ips> parameters can be arranged in any order
Example
Disable both LPS and IPS power-saving mechanisms:
AT+WLPS=lps,0,ips,0
OK