AT Commands
Introduction
AT commands are used for controlling modem, GSM, and many other types of communication equipment that come with a serial port. CommFront’s device servers / serial to Ethernet converters use AT commands for querying or setting parameters such as COM port and IP parameters.
AT Command Syntax
“AT” stands for “attention”, and it must be used at the beginning of each command line. The AT command must be terminated with a <CR> code (HEX code: 0D). AT commands are usually responded to by the device, and the response looks something like: “AT+COMMAND<CR><CR><LF><response><CR><LF>”. Throughout this document, only the responses are presented. “<CR><LF>” is omitted intentionally.
Command syntax
Query command:
AT+COMMAND<CR>
Set command:
AT+COMMAND=<parameter1,parameter2,…><CR>
Response syntax
Query command:
+OK=<parameter1,parameter2,…>
Set command:
+OK
Error:
+ERR=<number>
Error codes
Error Code | Description |
---|---|
1 | Invalid format |
2 | Invalid command |
3 | Invalid operator |
4 | Invalid parameter |
5 | Invalid operation |
Software Tools and Examples
The example below demonstrates how CommFront’s device servers / serial to Ethernet converters use AT commands for querying and setting network parameters.
- CommFront’s 232Analyzer software provides an easy and fast way for sending AT commands (download link: https://www.commfront.com/pages/downloads).
- Run the 232Analyzer software and set the COM port settings to 115.2Kbps, 8, N, 1. Then select “ASCII” for both TX and RX data formats.
- To enter AT Command mode, first send the ASCII code: +++
- The device server responds with an ASCII code: a
- Send the second ASCII code within 3 seconds: a
- The device server responds with an ASCII code and it now enters into “AT Command” mode: +ok
- Query current network settings: AT+WANN<CR>
- The device server responds with the current network settings: +OK=STATIC,192.168.1.201,255.255.255.0,192.168.1.254
- Change current network settings to the same sub network as your PC’s, e.g.: AT+WANN=STATIC,172.16.0.100,255.255.255.0,172.16.0.1
<CR>
- The device server responds with a confirmation code: +OK
- Restart the device server for the new settings to take effect: AT+Z<CR>
- The device server restarts and exits the “AT command” mode.
AT Commands Set
Command | Response |
---|---|
+++ |
a |
Send next command within 3 seconds |
|
a |
+ok |
|
Enter AT Command mode |
- Switch from AT command mode to data mode
Command | Response |
---|---|
AT+ENTM<CR> |
+OK |
|
Exit AT Command mode |
- Restart the device
Command | Response |
---|---|
AT+Z<CR> |
+OK |
|
Restart the device and exit AT Command mode |
- Restore factory settings
Command | Response |
---|---|
AT+RELD<CR> |
+OK |
|
Require device restart for factory settings to take effect |
- Query MAC address
Command | Response |
---|---|
AT+MAC<CR> |
+OK=<MAC> |
|
Example: +OK=D8C561010001 |
- Query or set Network parameters
Command | Response |
---|---|
AT+WANN<CR> |
+OK=<type,IP_address,subnet_mask,gateway> |
AT+WANN=<type,IP_address,subnet_mask,gateway><CR> |
+OK |
Example: AT+WANN=STATIC, |
|
- Query or set DNS address
Command | Response |
---|---|
AT+DNS<CR> |
+OK=<address> |
AT+DNS=<address><CR> |
+OK |
Example: AT+DNS=8.8.8.8<CR> |
|
- Query or set COM port parameters
Command | Response |
---|---|
AT+UART<CR> |
+OK=<baud_rate,data_bit,stop_ |
AT+UART=<baud_rate,data_bit,stop_ |
+OK |
Baud rate: 9600,19200,38400,57600, Stop bit: 1,2 Parity: None, Even, Odd, Mask, Space Flow Ctrl: No Hardware Control (NFC), Hardware Control (FCH) |
|
Example: AT+UART=115200,8,1,NONE,NFC<CR> |
|
- Query or set Socket parameters
Command | Response |
---|---|
AT+SOCK<CR> |
+OK=<socket,IP,port> |
AT+SOCK=<socket,IP,port><CR> |
+OK |
Socket: TCPC – TCP Client UDPS – UDP Server UDPC – UDP Client HTPC – Httpd Client IP: Remote IP address or domain Port: Local port (for server) or Remote port (for client) |
|
Example 1: AT+SOCK=TCPS, Example 2: AT+SOCK=TCPC, |
|
- Query TCP connection status
Command | Response |
---|---|
AT+SOCKLK<CR> |
+OK=<status> |
Status: CONNECT – TCP connection has been established DISCONNECT – TCP connection has not been established |
|
|
Example: +OK=CONNECT |
- Query or set Local port
Command | Response |
---|---|
AT+SOCKPORT<CR> |
+OK=<number> |
AT+SOCKPORT=<number><CR> |
+OK |
Number: 0 – Random 1-65535 – Local port |
|
Example: AT+SOCKPORT=502<CR> |
|
- Query Production time
Command | Response |
---|---|
AT+PDTIME<CR> |
+OK=<time> |
|
Example: +OK=2021-01-01 15:43:11 |
- Query or set Registry packet type
Command | Response |
---|---|
AT+REGEN<CR> |
+OK=<type> |
AT+REGEN=<type><CR> |
+OK |
Type: OFF: No registry packet is used MAC – Use MAC address as registry packet USR – Use user-defined packet CLOUD – Use cloud packet |
|
Example: AT+REGEN=MAC<CR> |
|
- Query or set When to send registry packet
Command | Response |
---|---|
AT+REGTCP<CR> |
+OK=<type> |
AT+REGTCP=<type><CR> |
+OK |
Type: FIRST – Send together with connection string EVERY – Send together with data string ALL – Send together with connection and data string |
|
Example: AT+REGTCP=FIRST<CR> |
|
- Query or set Device ID and cloud key for cloud connection
Command | Response |
---|---|
AT+REGCLOUD<CR> |
+OK=<deviceID,cloudKey> |
AT+REGCLOUD=<deviceID,cloudKey><CR> |
+OK |
Device ID – Device ID for cloud connection Cloud Key – Cloud key for cloud connection |
|
Example: AT+REGCLOUD=00000001,0001<CR> |
|
- Query or set User-defined registry packet
Command | Response |
---|---|
AT+REGUSR<CR> |
+OK=<data> |
AT+REGUSR=<data><CR> |
+OK |
Data: ASCII codes (up to 40 bytes) |
|
Example: AT+REGUSR=www.commfront.com |
|
- Query or set HTTP request method
Command | Response |
---|---|
AT+HTPTP<CR> |
+OK=<method> |
AT+HTPTP=<method><CR> |
+OK |
Method: GET – Use GET method for HTTP request POST – Use POST method for HTTP request |
|
Example: AT+HTPTP=GET<CR> |
|
- Query or set HTTP request URL
Command | Response |
---|---|
AT+HTPURL<CR> |
+OK=<url> |
AT+HTPURL=<url><CR> |
+OK |
URL: Less than 100 characters |
|
Example: AT+HTPURL=/1.php<CR> |
|
- Query or set HTTP request header
Command | Response |
---|---|
AT+HTPHEAD<CR> |
+OK=<data> |
AT+HTPHEAD=<data><CR> |
+OK |
Header: Less than 200 characters |
|
Example: AT+HTPHEAD=User_Agent: Mozila/4.0<CR> |
|
- Enable or disable Remove HTTP request header
Command | Response |
---|---|
AT+HTPCHD<CR> |
+OK=<status> |
AT+HTPCHD=<status><CR> |
+OK |
Status: ON – Remove HTTP request header OFF – Keep HTTP request header |
|
Example: AT+HTPCHD=OFF<CR> |
|
- Enable or disable Heartbeat function
Command | Response |
---|---|
AT+HEARTEN<CR> |
+OK=<status> |
AT+HEARTEN=<status><CR> |
+OK |
Status: OFF – Disable heartbeat function |
|
Example: AT+HEARTEN=ON<CR> |
|
- Query or set Direction to send heartbeat packet
Command | Response |
---|---|
AT+HEARTTP<CR> |
+OK=<type> |
AT+HEARTTP=<type><CR> |
+OK |
Type: COM – Send heartbeat packet to COM port NET – Send heartbeat packet to network port |
|
Example: AT+HEARTTP=NET<CR> |
|
- Query or set Heartbeat interval
Command | Response |
---|---|
AT+HEARTTM<CR> |
+OK=<time> |
AT+HEARTTM=<time><CR> |
+OK |
Time: 1 – 65535s |
|
Example: AT+HEARTTM=30<CR> |
|
- Query or set Heartbeat packet
Command | Response |
---|---|
AT+HEARTDT<CR> |
+OK=<data> |
AT+HEARTDT=<data><CR> |
+OK |
Data: ASCII codes (up to 40 bytes) |
|
Example: AT+HEARTDT=www.commfront.com<CR> |
|
- Enable or disable Restart after 30 times of unsuccessful connection attempts (TCP client mode)
Command | Response |
---|---|
AT+CLIENTRST<CR> |
+OK=<status> |
AT+CLIENTRST=<status><CR> |
+OK |
Status: ON – Enable restart after 30 times of unsuccessful TCP connection attempts OFF – Disable restart after 30 times of unsuccessful TCP connection attempts |
|
Example: AT+CLIENTRST=ON<CR> |
|
- Enable or disable Link function
Command | Response |
---|---|
AT+SCSLINK<CR> |
+OK=<status> |
AT+SCSLINK=<status><CR> |
+OK |
Status: ON – Socket link function is ON OFF – Socket link function is OFF |
|
Example: AT+SCSLINK=ON<CR> |
|
- Enable or disable Index function (TCP server mode)
Command | Response |
---|---|
AT+INDEXEN<CR> |
+OK=<status> |
AT+INDEXEN=<status><CR> |
+OK |
Status: ON – Enable index function OFF – Disable index function |
|
Example: AT+INDEXEN=ON<CR> |
|
- Enable or disable RFC2217
Command | Response |
---|---|
AT+RFCEN<CR> |
+OK=<status> |
AT+RFCEN=<status><CR> |
+OK |
Status: ON – Enable RFC2217 OFF – Disable RFC2217 |
|
Example: AT+RFCEN=ON<CR> |
|
- Enable or disable Short connection function
Command | Response |
---|---|
AT+SOCKSL<CR> |
+OK=<status> |
AT+SOCKSL=<status><CR> |
+OK |
Status: ON – Enable short connection function OFF – Disable short connection function |
|
Example: AT+SOCKSL=ON<CR> |
|
- Query or set Short connection timeout
Command | Response |
---|---|
AT+SHORTO<CR> |
+OK=<time> |
AT+SHORTO=<time><CR> |
+OK |
Time: 2-255s |
|
Example: AT+SHORTO=3<CR> |
|
- Query or set Server actions when maximum number of client connections is reached
Command | Response |
---|---|
AT+TCPSE<CR> |
+OK=<action> |
AT+TCPSE=<action><CR> |
+OK |
Status: KEEP – Keep old connection KICK – Disable old connection and allow new connection |
|
Example: AT+TCPSE=KEEP<CR> |
|
- Enable or disable Clear serial buffer upon TCP/IP connection
Command | Response |
---|---|
AT+UARTCLBUF<CR> |
+OK=<status> |
AT+UARTCLBUF=<status><CR> |
+OK |
Status: ON – Enable Clear serial buffer upon TCP/IP connection OFF – Disable Clear serial buffer upon TCP/IP connection |
|
Example: AT+UARTCLBUF=ON<CR> |
|
- Enable or disable Modbus RTU to Modbus TCP conversion
Command | Response |
---|---|
AT+MODTCP<CR> |
+OK=<status> |
AT+MODTCP=<status><CR> |
+OK |
Status: ON – Enable Modbus RTU to Modbus TCP conversion OFF – Disable Modbus RTU to Modbus TCP conversion |
|
Example: AT+MODTCP=ON<CR> |
|
- Query or set Device name
Command | Response |
---|---|
AT+MID<CR> |
+OK=<name> |
AT+MID=<name><CR> |
+OK |
Name: Up to 14 characters |
|
Example: AT+MID=DVS-485-2<CR> |
|
- Query or set Web port
Command | Response |
---|---|
AT+WEBPORT<CR> |
+OK=<port> |
AT+WEBPORT=<port><CR> |
+OK |
Example: AT+WEBPORT=80<CR> |
|
- Query or set User_name and password
Command | Response |
---|---|
AT+WEBU<CR> |
+OK=<username,password> |
AT+WEBU=<username,password><CR> |
+OK |
Example: AT+WEBU=user,password<CR> |
|
- Query Firmware version
Command | Response |
---|---|
AT+VER<CR> |
+OK=<ver> |
- Query or set Maximum number or client connections (server mode)
Command | Response |
---|---|
AT+MAXSK<CR> |
+OK=<number> |
AT+MAXSK=<number><CR> |
+OK |
Number: 1 to 8 |
|
Example: AT+MAXSK=8<CR> |
|
- Query or set No data auto-restart timeout
Command | Response |
---|---|
AT+RSTIM<CR> |
+OK=<time> |
AT+RSTIM=<time><CR> |
+OK |
Time: 0 – No auto-restart 60-65535s – Auto-restart timeout if no data received from serial or network port |
|
Example: AT+RSTIM=3600<CR> |
|
- Get Help information
Command | Response |
---|---|
AT+H<CR> |
+OK=<info> |