Quectel EC20 TCPIP at Commands Manual
Quectel EC20 TCPIP at Commands Manual
AT Commands Manual
Rev. EC20_TCPIP_AT_Commands_Manual_V1.0
Date: 2015-05-08
www.quectel.com
LTE Module Series
EC20 TCPIP AT Commands Manual
Our aim is to provide customers with timely and comprehensive service. For any
assistance, please contact our company headquarters:
l
http://www.quectel.com/support/salesupport.aspx
t e
For technical support, to report documentation errors, please visit:
c l
http://www.quectel.com/support/techsupport.aspx
a
Or Email: Support@quectel.com
GENERAL NOTES
u e n t i
QUECTEL OFFERS THIS INFORMATION AS A SERVICE TO ITS CUSTOMERS. THE INFORMATION
Q ide
PROVIDED IS BASED UPON CUSTOMERS’ REQUIREMENTS. QUECTEL MAKES EVERY EFFORT
TO ENSURE THE QUALITY OF THE INFORMATION IT MAKES AVAILABLE. QUECTEL DOES NOT
MAKE ANY WARRANTY AS TO THE INFORMATION CONTAINED HEREIN, AND DOES NOT ACCEPT
f
ANY LIABILITY FOR ANY INJURY, LOSS OR DAMAGE OF ANY KIND INCURRED BY USE OF OR
RELIANCE UPON THE INFORMATION. ALL INFORMATION SUPPLIED HEREIN IS SUBJECT TO
n
CHANGE WITHOUT PRIOR NOTICE.
o
COPYRIGHT
C
THIS INFORMATION CONTAINED HERE IS PROPRIETARY TECHNICAL INFORMATION OF
QUECTEL CO., LTD. TRANSMITTABLE, REPRODUCTION, DISSEMINATION AND EDITING OF THIS
DOCUMENT AS WELL AS UTILIZATION OF THIS CONTENTS ARE FORBIDDEN WITHOUT
PERMISSION. OFFENDERS WILL BE HELD LIABLE FOR PAYMENT OF DAMAGES. ALL RIGHTS
ARE RESERVED IN THE EVENT OF A PATENT GRANT OR REGISTRATION OF A UTILITY MODEL
OR DESIGN.
Copyright © Quectel Wireless Solutions Co., Ltd. 2015. All rights reserved.
History
el
Revision Date Author Description
t l
1.0 2015-05-08 Chris PENG Initial
e c t ia
u
Q ide n
n f
Co
Contents
1 Introduction .......................................................................................................................................... 5
1.1. The Process of Using TCPIP AT Commands .............................................................................. 5
1.2. Description of Data Access Mode................................................................................................ 7
l
2.2. AT+QIACT Activate PDP Context ............................................................................................. 9
2.3. AT+QIDEACT Deactivate PDP Context .................................................................................. 10
e
2.4. AT+QIOPEN Start Socket Service .......................................................................................... 10
t
2.5. AT+QICLOSE Close Socket Service ...................................................................................... 12
c l
2.6. AT+QISTATE Query Socket Service Status ............................................................................ 13
2.7. AT+QISEND Send Data .......................................................................................................... 15
e ia
2.8. AT+QIRD Retrieve the Received TCP/IP Data ....................................................................... 17
t
2.9. AT+QISENDEX Send HEX String ........................................................................................... 18
u
2.10. AT+QISWTMD Switch Data Access Mode .............................................................................. 19
n
2.11. AT+QPING Ping a Remote Server .......................................................................................... 20
Q ide
2.12. AT+QNTP Synchronize Local Time with NTP Server ............................................................. 21
2.13. AT+QIDNSCFG Configure Address of DNS Server ................................................................ 22
2.14. AT+QIDNSGIP Get IP Address by Domain Name .................................................................. 23
f
2.15. AT+QICFG Configure Optional Parameters............................................................................ 23
2.16. AT+QISDE Control Whether or Not to Echo the Data for QISEND ........................................ 25
n
2.17. AT+QIGETERROR Query the Last Error Code ...................................................................... 26
2.18. Description of URC .................................................................................................................... 26
o
2.18.1. URC of Connection Closed ............................................................................................ 26
2.18.2. URC of Incoming Data ................................................................................................... 27
C
2.18.3. URC of Incoming Connection Full ................................................................................. 27
2.18.4. URC of Incoming Connection ........................................................................................ 27
2.18.5. URC of PDP Deactivation .............................................................................................. 28
4 Example .............................................................................................................................................. 31
4.1. Configure and Activate Context ................................................................................................. 31
4.1.1. Configure Context .......................................................................................................... 31
4.1.2. Activate Context ............................................................................................................. 31
4.1.3. Deactivate Context ......................................................................................................... 31
4.2. TCP Client Works in Buffer Access Mode ................................................................................. 31
4.2.1. Set up a TCP Client Connection and Enter into Buffer Access Mode ........................... 31
4.2.2. Send Data in Buffer Access Mode ................................................................................. 32
4.2.3. Receive Data from Remote Server in Buffer Access Mode ........................................... 32
4.2.4. Close Connection ........................................................................................................... 33
l
4.5.1. Start a TCP Server ......................................................................................................... 35
4.5.2. Accept TCP Incoming Connection ................................................................................. 35
e
4.5.3. Receive Data from Incoming Connection ...................................................................... 36
t
4.5.4. Close TCP Server .......................................................................................................... 36
c l
4.6. Example of UDP Service ........................................................................................................... 36
a
4.6.1. Start UDP Service .......................................................................................................... 36
e i
4.6.2. Send UDP Data to Remote ............................................................................................ 37
u t
4.6.3. Receive Data from Remote ............................................................................................ 37
n
4.6.4. Close UDP Service ........................................................................................................ 37
4.7. PING........................................................................................................................................... 37
Q ide
4.8. Synchronize Local Time ............................................................................................................. 38
4.9. Example of Getting Last Error Code .......................................................................................... 38
n f
Co
1 Introduction
The module embeds a TCP/IP stack. Host is able to access the Internet directly over AT commands. It
can reduce the dependence on the PPP and TCP/IP protocol stack and thus minimize the cost. The
module provides the following socket services: TCP client, UDP client, TCP server and UDP service.
el
1.1. The Process of Using TCPIP AT Commands
c t l
Through TCPIP AT commands, host can configure PDP context, activate/deactivate PDP context,
e ia
start/close socket service and send/receive data via socket service. Figure 1 illustrates how to use TCPIP
t
AT commands:
u
Q ide n
n f
Co
PS Service:
l
Register to CS domain service in 60s
1. <stat> of AT+CGREG?/AT+CEREG?
equales to 1 or 5, means the module has
Query PS service in 60s by
registered to PS domain service in
e
AT+CGREG?/
UMTS/LTE network.
AT+CEREG?
t
2. Go to next step no matter register to PS
domain service or not in 60s.
c l
Configure PDP Context:
1. Configure APN, user name, password Configure PDP context and Qos by
a
and auth type by AT+QICSGP. AT+QICSGP/AT+CGQREQ/
e
2. Configure QoS settings by AT+CGEQREQ/AT+CGQMIN/
i
AT+CGQMIN/AT+CGEQMIN/ AT+CGEQMIN
t
AT+CGQREQ/AT+CGEQREQ.
u
Activate PDP Context:
n
1. Activate PDP context by
AT+QIACT=<contextID>. Reboot the 1. Reboot the module if
Succeed to
Q ide
2. Query IP address of PDP context module if Activate PDP context by there is no response in 150s.
deactivate AT+QIACT=<contextID> 2. If failed to deactivate
by AT+QIACT?. there is no
PDP and AT+QIACT? PDP context for 3 times,
Notes: response in
context then reboot the module.
a) All above commands should be 40s.
executed together in sequence.
b) Reboot the module if there is no Fail to activate
PDP context Succeed to activate PDP context
response for AT+QIACT in 150s.
f
c) If failed to deactivate PDP Deactivate
context for 3 times, then reboot the PDP context by Open connection
module.
n
AT+QIDEACT= by AT+QIOPEN
3. Deactivate PDP context: <contextID>
Reboot the module if there is no
response for AT+QIDEACT in 40s. 1. Fail to open connection
o
continuously for 5 times. +QIOPEN: <connectID>,<err>
Open Connection: 2. There is no response in 150s.
1. If failed to get response of AT+QIOPEN in 150s, then
C
close connection.
Send data by
2. If failed to open connection for 5 times, deactivate PDP
AT+QISEND=<connectID>
context, then re-activate PDP context and open connection
again.
Get ACK
in 90s
TCP Connection Maintenance and Detection: Query sending
1. Send data by AT+QISEND =<connectID>[,<send_length>]. ACK by AT+QISEND=
It is recommended to periodically send a small data packet to the remote <connectID>,0
end to maintian and detect the TCP connection.
2. Query sending ACK by AT+QISEND=<connectID>,0.
If the package is still not acknowledged after two minutes (query every 5 Fail to get ACK in 90s
seconds, 24 times in total), the TCP connection may be abnormal,
execute AT+QICLOSE to close the current connection, and then execute
AT+QIOPEN to re-establish the TCP connection. Close connection
OK
by AT+QICLOSE=
<connectID>
Reboot the module if there is
no response in 10s.
Notes:
1. Please note that you need to wait for the final response (for example OK, CME error, CMS error) of the last AT command you entered before
you enter the next AT command. You can reboot the module if the module failed to get response in 60s.
2. Reboot the module if the module has not got response of AT+QIACT in 150s or response of AT+QICLOSE in 10s and AT+QIDEACT in 40s .
3. When you constantly failed to restart for 3 times, you can restart immediately for the first time after that, if it still fails, you should restart after
10 minutes for the second time, and restart after 30 minutes for the third time, 1 hour for the fourth time, etc..
The TCPIP AT commands of the module include three kinds of data access modes:
When opening a socket service via AT+QIOPEN, specify the data access mode by the parameter
<access_mode>. After a socket service is opened, AT+QISWTMD could be used to change the data
l
access mode.
e
1. In buffer access mode, send data by AT+QISEND. When the data has been received, the module will
t
buffer the data and report an URC as +QIURC: “recv”,<connectID>. Then host can read data by
c l
AT+QIRD. Note: If the buffer is not empty, the module will not report a new URC until all the received
a
data has been read by AT+QIRD from buffer.
u e t i
2. In direct push mode, send data by AT+QISEND. The received data will be outputted to COM port
directly by +QIURC: “recv”,<connectID>,<currectrecvlength><CR><LF><data>.
Q ide n
3. In transparent access mode, the corresponding port (such as UART, USB modem port, etc.) enters
into the exclusive mode (Note that the USB AT port does not support transparent access mode). The
data received from COM port will be sent to Internet directly, and the received data from Internet will
f
be output to COM port directly as well. “+++” is used to exit from transparent access mode. When
“+++” returns OK, the module will be switched to buffer access mode. AT+QISWTMD can be used to
n
return back to transparent access mode. Note: In transparent access mode, host cannot execute AT
o
command. If the socket connection is closed because of network error or else, the module will report
NO CARRIER and exit from the transparent access mode. In this case, AT+QICLOSE should be
executed to close socket service.
C
4. To exit from the transparent access mode, use “+++” or DTR (AT&D1 should be set). To prevent the
“+++” from being misinterpreted as data, it should comply to the following sequence:
1) Do not input any character within T1 time (1 second) before inputting “+++”.
2) Input “+++” during 1s, and no other characters can be inputted during this time.
3) Do not input any character within T1 time (1 second) after “+++” has been inputted.
4) Exit from transparent access mode, return OK.
5. There are two methods to return back to the transparent access mode:
1) By AT+QISWTMD. Specify the <access_mode> as 2. If it enters into transparent access mode
successfully, CONNECT will be returned.
2) By ATO. ATO will change the access mode of connection that exits from transparent access mode
lately. If it enters into transparent access mode successfully, CONNECT will be returned. If there is
no connection enters into transparent access mode before, ATO will return NO CARRIER.
2 Description of AT Command
l
Configure the <APN>, <username>, <password> and other contexts by AT+QICSGP. The QoS of the
e
context can be configured by AT+CGQMIN, AT+CGEQMIN, AT+CGQREQ and AT+CGEQREQ.
t l
AT+QICSGP Configure Context
c
Test Command Response
e ia
AT+QICSGP=? +QICSGP: (1-16),1,<APN>,<username>,<password>,(0-3)
u t
OK
n
Query the configuration of context Response
Q ide
AT+QICSGP=<contextID> +QICSGP:
<context_type>,<APN>,<username>,<password>,<authent
ication>
f
OK
n
Write Command, configure the context Response
o
AT+QICSGP=<contextID>,<context_t OK
ype>,[<APN>[,<username>,<passwor ERROR
d>)[,<authentication>]]]
Parameter
<contextID>
<context_type>
<APN>
C Integer type, context ID, range is 1-16
Integer type, protocol type
1 IPV4
String type, access point name
<username> String type, username
<password> String type, password
<authentication> Integer type, the authentication methods
0 NONE
1 PAP
2 CHAP
3 PAP_OR_CHAP
Example
OK
AT+QICSGP=1,1,"UNINET","","",1 //Configure context 1, APN is “UNINET” for China Unicom.
OK
l
2.2. AT+QIACT Activate PDP Context
t e
Before activating context by AT+QIACT, host should configure the context by AT+QICSGP. After activation,
l
the IP address can be queried by AT+QIACT?. The range of <contextID> is 1-16, but the maximum
c
number of context which can be activated at the same time is 3. Depending on the Network, it may take at
e ia
most 150 seconds to return OK or ERROR after executing AT+QIACT. Before the response is returned,
t
other AT commands cannot be executed.
u n
AT+QIACT Activate PDP Context
Q ide
Test Command Response
AT+QIACT=? +QIACT: (1-16)
OK
f
Read command Response
n
AT+QIACT? Return the list of the current activated context and its IP
address:
o
+QIACT:
1,<context_state>,<context_type>[,<IP_address>]
C
[.....
+QIACT:
16,<context_state>,<context_type>[,<IP_address>]]
OK
Write Command Response
AT+QIACT=<contextID> Activate the context of specified <contextID>:
OK
ERROR
Parameter
l
2.3. AT+QIDEACT Deactivate PDP Context
t e l
AT+QIDEACT will deactivate the specific context <contextID> and close all TCPIP connections set up in
c
this context. Depending on the Network, it may take at most 40 seconds to return OK or ERROR after
e a
executing AT+QIDEACT. Before the response is returned, other AT commands cannot be executed.
u t i
AT+QIDEACT Deactivate PDP Context
n
Test Command Response
Q ide
AT+QIDEACT=? OK
Write Command Response
AT+QIDEACT=<contextID> OK
f
ERROR
n
Maximum Response Time 40 seconds, determined by network.
o
Parameter
C
<contextID> Integer type, context ID, range is 1-16
Start a socket service by AT+QIOPEN. The service type can be specified by the parameter
<service_type>. The data access mode (buffer access mode, direct push access mode and transparent
access mode) can be specified by parameter <access_mode>. The URC “+QIOPEN” indicates whether
the socket service is started successfully.
1. If <service_type> is “TCP LISTENER”, module works as TCP SERVER. After accepting a new TCP
connection, module will auto specify a <connectID> and report a URC as “+QIURC:
2. If <service_type> is “UDP SERVICE”, UDP data can be sent to or received from the remote IP via
<local_port>.
Send data: AT+QISEND=<connectID>,<send_length>,<remoteIP>,<remote_port>.
Receive data in direct push access mode: report a URC as “+QIURC:
“recv”,<connectID>,<currentrecvlength>,<remoteIP>,<remote_port><CR><LF><data>”
Receive data in buffer access mode: report a URC as +QIURC: “recv”,<connectID>, then
retrieve data by AT+QIRD=<connectID>.
l
3. It is suggested to wait 150 seconds for the URC response as “+QIOPEN: <connectID>,<err>”. If the
e
URC response has not been received in 150 seconds, host could use AT+QICLOSE to close the
t
socket.
c a l
AT+QIOPEN Start Socket Service
e i
Test Command Response
u t
AT+QIOPEN=? +QIOPEN: (1-16),(0-11),"TCP/UDP/TCP LISTENER/UDP
n
SERVICE","<IP_address>/<domain_name>",<remote_port
>,<local_port>,(0-2)
Q ide
OK
Read Command Response
f
AT+QIOPEN?
n
OK
Write Command Response
o
AT+QIOPEN=<contextID>,<connectID If the <access_mode> is transparent access mode and it is
>,<service_type>,<IP_address>/<dom successful to start the service, response:
C
ain_name>,<remote_port>[,<local_po CONNECT
rt>[,<access_mode>]] Else, response:
ERROR
Error description can be got via AT+QIGETERROR.
+QIOPEN: <connectID>,<err>
<err> is 0 when service is started successfully, else
<err> is not 0.
Parameter
l
“220.180.239.201”
If <service_type> is TCP LISTENER or UDP SERVICE, please enter “127.0.0.1”
e
<domain_name> String type, the domain name address of the remote server
t
<remote_port> The port of the remote server, only valid when <service_type> is “TCP” or “UDP”,
c l
range is 0-65535
a
<local_port> The local port, range is 0-65535
e i
If <service_type> is “TCP LISTENER” or “UDP SERVICE”, this parameter must be
u t
specified
n
If <service_type> is “TCP” or “UDP”, if <local_port> is 0, then the local port will be
assigned automatically, else the local port is assigned as specified
Q ide
<access_mode> Integer type, the data access mode of the socket services
0 Buffer access mode
1 Direct push mode
f
2 Transparent access mode
<err> Integer type, error code. Please refer to Chapter 3 for details
2.5. AT+QICLOSE
C
Close the specified socket service by AT+QICLOSE. Depending on the Network, it will take at most 10
seconds (default value, host could modify the time with <timeout>) to return OK or ERROR after
executing AT+QICLOSE. Before the response is returned, other AT commands cannot be executed.
ERROR
Parameter
l
2.6. AT+QISTATE Query Socket Service Status
c t e l
AT+QISTATE can be used to query the socket service status. If the <query_type> is 0, it will return the
a
status of all existing socket services in the context of specified <contextID>. If the <query_type> is 1, it will
e i
return the status of specified <connectID> socket service.
u t
AT+QISTATE Query Socket Service Status
n
Test Command Response
Q ide
AT+QISTATE=? OK
Read Command Response
AT+QISTATE? Return the status of all existing connections
f
List of (+QISTATE:
<connectID>,<service_type>,<IP_address>,<remote_port>
n
,<local_port>,<socket_state>,<contextID>,<serverID>,<ac
o
cess_mode>,<AT_port>)
C
OK
If <query_type> is 0, query by specified Response
<contextID> Return the status of all existing connections in specified
AT+QISTATE=<query_type>,<context <contextID>
ID> List of (+QISTATE:
<connectID>,<service_type>,<IP_address>,<remote_port>
,<local_port>,<socket_state>,<contextID>,<serverID>,<ac
cess_mode>,<AT_port>)
OK
If <query_type> is 1, query by specified Response
<connectID> +QISTATE:
AT+QISTATE=<query_type>,<connect <connectID>,<service_type>,<IP_address>,<remote_port>
ID> ,<local_port>,<socket_state>,<contextID>,<serverID>,<ac
cess_mode>,<AT_port>
OK
Parameter
l
<connectID> Integer type, socket service index, range is 0-11
<service_type> String type, the service type
e
“TCP” TCP connection as a client
t
“UDP” UDP connection as a client
c l
“TCP LISTENER” TCP listener socket as a TCP server
a
“TCP INCOMING” TCP connection accepted by a TCP server
e i
“UDP SERVICE” UDP service
t
<IP_address> IP address
u
If <service_type>=“TCP” or “UDP”, <IP_address> is the IP address of remote server
n
If <service_type>=“TCP LISTENER” or “UDP SERVICE”, <IP_address> is local IP
Q ide
address
If <service_type>=“TCP INCOMING”, <IP_address> is the IP address of remote client
<remote_port> Remote port number
f
If <service_type>=“TCP” or “UDP”, <remote_port> is the port of remote server
If <service_type>=“TCP LISTENER” or “UDP SERVICE”, <remote_port> is invalid
n
If <service_type>=“TCP INCOMING”, <remote_port> is the port of remote client
<local_port> Local port number
o
If <local_port> is 0, local port is assigned automatically
<socket_state> Integer type, socket service state
C
0 “Initial” connection has not been established
1 “Opening” client is connecting or server is trying to listen
2 “Connected” client/incoming connection has been established
3 “Listening” server is listening
4 “Closing” connection is closing
<serverID> Only valid when <service_type> is “TCP INCOMING”. <serverID> represents which
server accepts this TCP incoming connection, the value is the same as <connectID> of
this server’s “TCP LISTENER”
<access_mode> Data access mode
0 Buffer access mode
1 Direct push mode
2 Transparent access mode
<AT_port> String type, COM port of socket service
“usbmodem” USB MODEM PORT
l
If <access_mode> of the specified socket service is buffer access mode or direct push mode, send data
by AT+QISEND. If data is sent to the module successfully, return “SEND OK”, else return “SEND FAIL” or
t e
“ERROR”. “SEND FAIL” indicates the send buffer is full and host can try to resend the data. “ERROR”
l
indicates it encounters error in the process of sending data. The host should delay some time for sending
c
data. The maximum length of sending data is 1460. “SEND OK” does not mean the data has been sent to
e a
the server successfully. Through the “AT+QISEND=<connectID>, 0” command, host can query whether
t i
the data has reached the server.
u n
AT+QISEND Send Data
Q ide
Test Command Response
AT+QISEND=? +QISEND: (0-11),(0-1460)
OK
f
If<service_type> is “TCP”, “UDP” or Response
n
“TCP INCOMING”, send data with >
changeable length <input data>
o
AT+QISEND=<connectID> CTRL+Z
Response “>”, then type data to send,
C
tap CTRL+Z to send, tap ESC to cancel If connection has been established and sending is successful,
the operation response:
SEND OK
l
If <service_type> is “UDP SERVICE” Response
e
AT+QISEND=<connectID>,<send_len This command is used to send fixed length data to specified
t
gth>,<remoteIP>,<remote_port> remote IP address and remote port. The <service_type> must
l
Response “>”, type data until the data be “UDP SERVICE”.
c
length is equal to <send_length> >
e a
<input data with specified length>
u t i
If connection has been established and sending is successful,
n
response:
Q ide
SEND OK
f
SEND FAIL
n
If connection has not been established, abnormally closed, or
o
parameter is incorrect, response:
ERROR
C
When <send_length> is 0, query the Response
sent data If the specified <connectID> connection has existed, return:
AT+QISEND=<connectID>,0 +QISEND:
<total_send_length>,<ackedbytes>,<unackedbytes>
OK
Else, return:
ERROR
Parameter
l
In buffer access mode, after receiving data, the module will buffer it and report a URC as +QIURC:
“recv”,<connectID> to notify the host. Then host can retrieve data by AT+QIRD.
t e l
Notes: If the buffer is not empty, and the module receives data again, then it will not report a new URC
c
until all the received data has been retrieved by AT+QIRD from buffer.
e ia
AT+QIRD Retrieve the Received TCP/IP Data
u t
Test Command Response
n
AT+QIRD=? +QIRD: (0-11),(0-1500)
Q ide
OK
When <service_type> is Response
“TCP”/“UDP”/“TCP INCOMING”
f
If the specified connection has received data, response:
AT+QIRD=<connectID>[,<read_length +QIRD: <read_actual_length><CR><LF><data>
n
>]
OK
o
If no data, return:
+QIRD: 0
C
OK
OK
OK
If connection does not exist, return:
ERROR
When <read_length> is 0, query Response
retrieved data If the specified connection has existed, return:
AT+QIRD=<connectID>,0 +QIRD:
<total_receive_length>,<have_read_length>,<unread_leng
th>
OK
l
Else response:
ERROR
Parameter
c t e l
e ia
<connectID> Integer type, the socket service index, the range is 0-11
u t
<read_length> The maximum length of data to be retrieved, the range is 0-1500
n
<read_actual_length> The actual length of received data
<remoteIP> String type, the remote IP address, only valid when <service_type> is “UDP
Q ide
SERVICE”
<remote_port> Integer type, the remote port, only valid when <service_type> is “UDP
SERVICE”
f
<data> The retrieved data
<total_receive_length> The total length of received data
n
<have_read_length> The read length of received data
o
<unread_length> The unread length of received data
C
2.9. AT+QISENDEX Send HEX String
This command cannot be applied for “UDP SERVICE” and “TCP LISTENER” Socket.
OK
Write Command Response
AT+QISENDEX=<connectID>,<h SEND OK
ex_string>
If no data, return:
SEND FAIL
Parameter
<connectID> Integer type, the socket service index, the range is 0-11
<hex_string> String type, hex string, the max length is 512
t el
2.10. AT+QISWTMD Switch Data Access Mode
e c a l
AT+QISWTMD can switch the data access mode: buffer access mode, direct push mode and transparent
t i
access mode. When starting a socket service, host can specify the data access mode by the parameter
u
<access_mode> of AT+QIOPEN. After a socket has been started, host can change the data access mode
n
by AT+QISWTMD.
Q ide
AT+QISWTMD Switch Data Access Mode
Test Command Response
AT+QISWTMD=? +QISWTMD: (0-11),(0-2)
n f
OK
Read Command Response
o
AT+QISWTMD? OK
Write Command Response
C
AT+QISWTMD=<connectID>,<access If switch successfully and <access_mode> is 0 or 1, response:
_mode> OK
Parameter
<connectID> Integer type, the socket service index, the range is 0-11
<access_mode> Integer type, the data access mode of the connection
0 Buffer access mode
1 Direct push mode
2 Transparent access mode
el
AT+QPING is used to test the Internet Protocol reachability of a host. Before using ping tools, host should
t
activate the context corresponding to <contextID> via AT+QIACT first. It will return the result during
l
<timeout> and the default value of <timeout> is 4 second.
c a
AT+QPING Ping a Remote Server
e t i
Test Command Response
u
AT+QPING=? +QPING: (1-16),<host>,(1-255),(1-10)
Q ide n
OK
Write Command Response
AT+QPING=<contextID>,<host>[,<tim If ping successfully, return:
f
eout>[,<pingnum>]] OK
n
[+QPING:
<result>[,<IP_address>,<bytes>,<time>,<ttl>]<CR><LF>…]
o
+QPING:
<finresult>[,<sent>,<rcvd>,<lost>,<min>,<max>,<avg>]
C
Else response:
ERROR
Parameter
l
<lost> Total number of the ping requests that are timeout
<min> The minimum response time. Unit: ms
e
<max> The maximum response time. Unit: ms
t
<avg> The average response time. Unit: ms
e c ia l
t
2.12. AT+QNTP Synchronize Local Time with NTP Server
u
Q ide n
NTP is intended to synchronize the Coordinated Universal Time (UTC) with the time server. Before using
NTP, host should activate the context corresponding to <contextID> via AT+QIACT first. Depending on
the Network, it will take at most 125 seconds to return the result.
f
AT+QNTP Synchronize Local Time with NTP Server
n
Test command Response
AT+QNTP=? +QNTP: (1-16),<server>,(list of supported<port>s),(0,1)
o
OK
C
Read command Response
AT+QNTP? If in the process of synchronizing local time:
+QNTP: <server>,<port>
OK
Write command Response
AT+QNTP=<contextID>,<server> If synchronize local time with NTP server successfully:
[,<port>][,<autosettime>] OK
+QNTP: <err>,<time>
Else response:
ERROR
Maximum Response Time 125s, determined by network.
Parameter
2.13. AT+QIDNSCFG
e c a l
Before setting the DNS address, host must activate the context corresponding to <contextID> via
t i
AT+QIACT first.
u n
AT+QIDNSCFG Configure Address of DNS Server
Q ide
Test command Response
AT+QIDNSCFG=? +QIDNSCFG: (1-16),<pridnsaddr>,<secdnsaddr>
OK
f
Configure DNS server address for Response
n
specified PDP context OK
AT+QIDNSCFG=<contextID>,<pri ERROR
o
dnsaddr>[,<secdnsaddr>]
Query DNS server address of Response
C
specified PDP context +QIDNSCFG: <contextID>,<pridnsaddr>,<secdnsaddr>
AT+QIDNSCFG=<contextID>
OK
Parameter
Before querying the DNS, host should activate the context corresponding to <contextID> via AT+QIACT
first. Depending on the Network, it will take at most 60 seconds to return the result.
OK
l
Write Command Response
e
AT+QIDNSGIP=<contextID>,<hos
t
tname> OK
l
ERROR
c
The result will be returned as URC.
e a
+QIURC: "dnsgip",<err>,<IP_count>,<DNS_ttl>
t i
[.....
u
+QIURC: "dnsgip",<hostIPaddr>]
n
Maximum Response Time 60s, determined by network.
Q ide
Parameter
f
<contextID> Integer type, indicates PDP context ID, range is 1-16
n
<hostname> String type, indicates domain name
<err> Integer type, please refer to Chapter 3
o
<IP_count> Integer type, the number of the IP address corresponding to the <hostname>
<DNS_ttl> Integer type, the time of the DNS to live
C
<hostIPaddr> String type, the IP address of <hostname>
OK
l
ERROR
Set the data format for sending and Response
e
receiving (only for non-transparent
[+QICFG:
t
mode)
"dataformat",<send_data_format>,<recv_data_format>]
l
AT+QICFG=“dataformat”[,<send
c
_data_format>,<recv_data_forma
a
t>] OK
e i
ERROR
u t
Set the display format for receiving Response
data (only for non-transparent
n
[+QICFG: “viewmode”,<mode>]
mode)
Q ide
AT+QICFG=“viewmode”[,<view_
mode>] OK
ERROR
Set the maximum interval time and Response
f
number for TCP retransmission [+QICFG: "tcp/retranscfg",<max_backoffs>,<max_rto>]
AT+QICFG="tcp/retranscfg"[,<m
n
ax_backoffs>,<max_rto>]
OK
o
ERROR
C
Parameter
<transpktsize> Integer type, indicates the max length of sending data packet, range is
1-1460, default: 1024
<transwaittm> Integer type, in transparent access mode, if the length of data received from
the port is less than the specified value of <transpktsize>, after exceeding the
time of <transwaittm>, data will be sent directly. Unit: 100ms, range: 0-20,
default: 2
<send_data_format> Integer type
0 Text mode
1 Hex mode
<recv_data_format> Integer type
0 Text mode
1 Hex mode
<view_mode> Integer type
NOTE
t el
c l
2.16. AT+QISDE Control Whether or Not to Echo the Data for QISEND
e ia
AT+QISDE Control Whether or Not to Echo the Data for QISEND
u t
Test command Response
n
AT+QISDE=? +QISDE: (0,1)
Q ide
OK
Read command Response
f
AT+QISDE? +QISDE: <echo>
n
OK
o
Execution Command Response
AT+QISDE=<echo> OK
C
ERROR
Parameter
<echo> A numeric indicates whether or not to echo the data for AT+QISEND
0 Do not echo the data
1 Echo the data
If TCPIP AT commands respond ERROR, the details of error can be queried by AT+QIGETERROR.
Please note that AT+QIGETERROR just returns error code of the last TCPIP AT command.
el
OK
c t l
Parameter
e ia
<err> Integer type, error code. Please refer to Chapter 3
u t
<errcode_description> A string parameter indicates the details of error information. Please refer to
n
Chapter 3
Q ide
2.18. Description of URC
n f
The URC of TCPIP AT commands will be reported to the host by the type of “+QIURC:”. It contains the
reports about incoming data, connection closed and incoming connection and so on. Actually, there is
o
“<CR><LF>” both before and after URC, but “<CR><LF>” is omitted intentionally.
C
2.18.1. URC of Connection Closed
When TCP socket service is closed by remote peer or network error, this report will be outputted. The
<socket_state> of <connectID> will be “closing”. Host must execute AT+QICLOSE=<connectID> to
change the <socket_state> to “initial”.
Parameter
In buffer access mode or direct push mode, after receiving data, the module will report URC to host.
In buffer access mode, after receiving data, the module will report URC as +QIURC: “recv”,<connectID>
to notify the host. Then host can retrieve data by AT+QIRD. Notes: if the buffer is not empty, and the
module receives data again, it will not report a new URC until all the received data has been retrieved by
AT+QIRD from buffer. In direct push mode, the received data will be outputted to COM port directly.
l
can receive data by AT+QIRD.
e
+QIURC: The URC of incoming data in direct push mode when the
t
“recv”,<connectID>,<currentrecvleng <service_type> is “TCP”, “UDP” or “TCP INCOMING”.
l
th><CR><LF><data>
c
+QIURC: The URC of data incoming in direct push mode when
e ia
“recv”,<connectID>,<currentrecvleng <service_type> is “UDP SERVICE”.
t
th>,<remoteIP>,<remote_port><CR><
u
LF><data>
Q ide n
Parameter
f
<currentrecvlength> Integer type, the length of actual received data
n
<remoteIP> Remote IP address
<remote_port> Remote port
o
<data> The received data
C
2.18.3. URC of Incoming Connection Full
If the incoming connection reaches the limit, or no socket system resources can be allocated, then the
module will report the URC as +QIURC: “incoming full” for the new incoming connection request.
If the <service_type> is “TCP LISTENER”, when remote client connects to this server, host will auto
assign a free <connectID> for the new connection. The range of <connectID> is 0-11. The module will
report URC as below. The <service_type> of new connection is “TCP INCOMING”, and the
Parameter
<connectID> Integer type, assign this <connectID> for the incoming connection, which is auto
l
specified by the module. The range is 0-11
<serverID> The incoming <connectID> accepted by the server whose <service_type> is “TCP
e
LISTENER” and listening socket ID is <serverID>
t
<remoteIP> Remote IP address of the incoming <connectID>
c l
<remote_port> Remote port of the incoming <connectID>
e t ia
2.18.5. URC of PDP Deactivation
u n
PDP context may be deactivated by the network. The module will report URC to the host. Host must
Q ide
execute AT+QIDEACT to deactivate the context and reset all connections.
f
<contextID> context is deactivated.
n
Parameter
o
<contextID> Integer type, context ID, range is 1-16
C
EC20_TCPIP_AT_Commands_Manual Confidential / Released 28 / 38
L Module Series
EC20 TCPIP AT Commands Manual
l
Table 1: The Description of Error Code
t e
<err> Description of Error Code
c l
0 operate successfully
e ia
550 unknown error
u t
551 operation blocked
n
552 invalid parameters
Q ide
553 memory not enough
f
554 create socket failed
n
555 operation not supported
o
556 socket bind failed
C
558 socket write failed
l
572 operation not allowed
e
573 APN not configured
t l
574 port busy
e c t ia
u
Q ide n
n f
Co
4 Example
l
4.1.1. Configure Context
e
//Configure context 1, APN is “UNINET” for China Unicom.
t
AT+QICSGP=1,1,"UNINET","","",1
l
OK
e c ia
4.1.2. Activate Context
u n t
AT+QIACT=1 //Activate context 1. Depending on the Network, the maximum
response time is 150s.
Q ide
OK //Activate successfully.
AT+QIACT? //Query the state of context.
+QIACT: 1,1,1,"10.7.157.1"
f
OK
4.1.3.
o n
Deactivate Context
C
AT+QIDEACT=1 //Deactivate context 1.
OK //Deactivate successfully. Depending on the Network, the
maximum response time is 40s.
4.2.1. Set up a TCP Client Connection and Enter into Buffer Access Mode
+QIOPEN: 0,0 //Connect successfully. It is suggested to wait 150 seconds for the
URC response as “+QIOPEN: <connectID>,<err>”. If the URC
response has not been received in 150 seconds, host could use
AT+QICLOSE to close the socket.
AT+QISTATE=1,0 //Query if connection state of <connectID> is 0.
+QISTATE: 0,“TCP”,“220.180.239.201”,8705,65514,2,1,0,0,“usbmodem”
OK
l
4.2.2. Send Data in Buffer Access Mode
e
AT+QISEND=0 //Send changeable length data. “SEND OK” does not mean the
t
data has been sent to the server successfully. Host can query
c l
whether the data has reached the server via AT+QISEND=0,0.
a
>test1<ctrl+Z>
e i
SEND OK
u t
AT+QISEND=0,4 //Send fixed length data and the data length is 4.
n
>test
SEND OK
Q ide
AT+QISEND=0,0 //Query the length of sent data.
+QISEND: 9,9,0
f
OK
AT+QISENDEX=0,"3132333435" //Send HEX string.
n
OK
o
AT+QISEND=0,0 //Query the length of sent data.
+QISEND: 14,14,0
C
OK
OK
AT+QIRD=0,1500
+QIRD: 0 //No data in buffer.
OK
AT+QIRD=0,0 //Query length of total received data, including read and unread.
+QIRD: 5,5,0
OK
l
response time is 10s.
OK
c t e l
a
4.3. TCP Client Works in Transparent Access Mode
u e t i
4.3.1. Set up a TCP Client Connection and Enter into Transparent Access Mode
Q ide n
AT+QIOPEN=1,0,"TCP","220.180.239.201",8705,0,2 //Context is 1 and <connectID> is 0. Before using
AT+QIOPEN, host should activate the context
with AT+QIACT first.
CONNECT //Connect successfully. It is suggested to wait 150
f
seconds for the URC response as “CONNECT”.
n
If the URC response has not been received in
150 seconds, host could use AT+QICLOSE to
o
close the socket.
C
4.3.2. Send Data in Transparent Access Mode
<All data got from COM port will be sent to internet directly>
el
4.4.1. Set up TCP Client Connection and Enter into Direct Push Mode
c t l
AT+QIOPEN=1,0,"TCP","220.180.239.201",8705,0,1 //Context is 1 and <connectID> is 0. Before using
a
AT+QIOPEN, host should activate the context
e i
with AT+QIACT first.
u t
OK
n
+QIOPEN: 0,0 //Connect successfully. It is suggested to wait 150
Q ide
seconds for the URC response as “+QIOPEN:
<connectID>,<err>”. If the URC response has not
been received in 150 seconds, host could use
f
AT+QICLOSE to close the socket.
AT+QISTATE=1,0 //Query if connection state of <connectID> is 0.
n
+QISTATE: 0,“TCP”,“220.180.239.201”,8705,65344,2,1,0,1,“usbmodem”
o
OK
C
4.4.2. Send Data in Direct Push Mode
OK
el
AT+QICLOSE=0 //Close the connection of which <connectID>
t
is 0. Depending on the Network, the
l
maximum response time is 10s.
c
OK
u e t ia
n
4.5. TCP Server Works in Buffer Access Mode
Q ide
4.5.1. Start a TCP Server
f
AT+QIOPEN=1,1,"TCP LISTENER","127.0.0.1",0,2020,0 //Context is 1 and <connectID> is 1. Before
using AT+QIOPEN, host should activate the
n
context with AT+QIACT first.
OK
o
+QIOPEN: 1,0 //Start TCP server successfully.
C
AT+QISTATE=0,1 //Query if connection state of <contextID> is 1.
+QISTATE: 1,“TCP LISTENER”,“10.7.157.1”,0,2020,3,1,1,0,“usbmodem”
OK
OK
AT+QIRD=11,1500
+QIRD: 0 //No data in buffer.
l
OK
e
AT+QIRD=11,0 //Query the data length of total received, including
t
read and unread.
c l
+QIRD: 4,4,0
e ia
OK
u n t
4.5.4. Close TCP Server
Q ide
AT+QICLOSE=11 //Close incoming connection. Depending on the
Network, the maximum response time is 10s.
f
OK
AT+QICLOSE=1 //Close TCP server listening.
n
OK
4.6.1.
Co
4.6. Example of UDP Service
OK
l
4.6.3. Receive Data from Remote
e
+QIURC: “recv”,2 //Receive data from remote.
t
AT+QIRD=2 //Read UDP data. One whole UDP packet will be
c l
outputted. There is no need to specify the read
a
length.
e i
+QIRD: 4,“10.7.76.34”,7687 //Data length is 4, remote IP address is 10.7.76.34
u t
and remote port is 7687 test.
n
AAAA
Q ide
OK
AT+QIRD=2 //Read data.
+QIRD: 0 //No data in buffer.
f
OK
n
AT+QISEND=2,10,“10.7.76.34”,7687 //Send data to remote (10.7.76.34:7687).
>1234567890
o
SEND OK
C
4.6.4. Close UDP Service
4.7. PING
+QPING: 0,"61.135.169.125",32,192,255
+QPING: 0,"61.135.169.125",32,240,255
+QPING: 0,"61.135.169.125",32,241,255
+QPING: 0,"61.135.169.125",32,479,255
+QPING: 0,4,4,0,192,479,287
el
4.8. Synchronize Local Time
c t l
AT+QNTP=1,“202.120.2.101”,123 //Synchronize local time with NTP server
a
“202.120.2.101:123”. Before synchronizing the
e i
time, host should activate the context with
u t
AT+QIACT first.
n
OK
Q ide
+QNTP: 0,"2013/08/19,11:10:10+32"
AT+CCLK?
+CCLK: "13/08/19,11:10:57+32"
f
OK
o n
4.9. Example of Getting Last Error Code
C
AT+QIOPEN=1,"TCP","220.180.239.201",8033,0,1 //Start socket service, forget the <connectID>.
ERROR
AT+QIGETERROR
+QIGETERROR: 552, invalid parameters
OK