AT Commands Examples Application Note (GSM.G1-CS-09003)
AT Commands Examples Application Note (GSM.G1-CS-09003)
Abstract
This document provides detailed examples of how to use AT
commands with u-blox wireless modules.
www.u-blox.com
AT Commands Examples - Application Note
Document Information
Title AT Commands Examples
Examples for
Subtitle
u-blox wireless modules
Document type Application Note
Document number GSM.G1-CS-09003-C1
Document status Preliminary
This document and the use of any information contained therein, is subject to the acceptance of the u-blox terms and conditions. They
can be downloaded from www.u-blox.com.
u-blox makes no warranties based on the accuracy or completeness of the contents of this document and reserves the right to make
changes to specifications and product descriptions at any time without notice.
u-blox reserves all rights to this document and the information contained herein. Reproduction, use or disclosure to third parties without
express permission is strictly prohibited. Copyright © 2010, u-blox AG.
GSM.G1-CS-09003-C1 Page 2 of 39
AT Commands Examples - Application Note
Contents
Contents.............................................................................................................................. 3
1 Introduction .................................................................................................................. 5
4 GPRS connection......................................................................................................... 10
4.1 Context Activation .............................................................................................................................. 10
4.2 Context Deactivation .......................................................................................................................... 11
4.2.1 Context Deactivation by the network .......................................................................................... 11
4.2.1 Context Deactivation by the module ........................................................................................... 11
Appendix .......................................................................................................................... 36
Related documents........................................................................................................... 38
Contact .............................................................................................................................. 39
1 Introduction
This document provides examples of using AT commands. For more details on AT command description please
refer to u-blox 2G GSM/GPRS AT Commands Manual [1] or u-blox 3.5G HSDPA AT Commands Manual [4].
2 Storing parameters
Save parameters in the Non Volatile Memory (NVM). Retrieve parameters from NVM. For further details refer to
the command description of AT+CPWROFF, AT&V, AT&W, ATY in the u-blox 2G GSM/GPRS AT Commands
Manual [1] or u-blox 3.5G HSDPA AT Commands Manual [4].
STORED PROFILE 0:
&C1, &D1, &S1, &K3, E1, Q0,
V1, X4, S00:000, S02:043,
S03:013, S04:010, S05:008,
S07:255, +CBST:007, 000, 001,
+CRLP:061, 061, 048, 006,
+CR:000, +CRC:000,
+IPR:115200,
+COPS:0,0,FFFFF, +ICF:3,1,
+UPSV: 0, +CMGF:0,
+CNMI:1,0,0,0,0
STORED PROFILE 1:
&C1, &D1, &S1, &K3, E1, Q0,
V1, X4, S00:000, S02:043,
S03:013, S04:010, S05:008,
S07:255, +CBST:007, 000, 001,
+CRLP:061, 061, 048, 006,
+CR:000, +CRC:000,
+IPR:115200,
+COPS:0,0,FFFFF, +ICF:3,1,
+UPSV: 0, +CMGF:0,
+CNMI:1,0,0,0,0
OK
Default RAT configuration is GSM / UMTS Dual Mode with UMTS preferred access technology.
Any change in the RAT selection has to be done when the module is deregistered from the network.
Before changing the RAT deregister the module with AT+COPS=2 command.
After changing the RAT configuration to ensure that the new settings are saved in the NVM it’s
necessary to power off the module (AT+CPWROFF). Then switch on the module and repeat the steps
listed in chapter 3.1.1.
When a new RAT setting is saved in the NVM it’s not possible to load the RAT factory defined
configuration. You can restore this by performing the following steps:
If the module is registered in GSM / UMTS Dual Mode (AT+URAT=1,0 or AT+URAT=1,2) it is possible
to change preferred RAT technology but the new setting will take effect only after a period of lost
network coverage or if the module is deregistered and registered again on the network.
AT+URAT=0,2 and AT+URAT=2,0 are allowed but the second parameter is ignored. The second
parameter is applied by the module only in GSM / UMTS Dual mode Radio Access technology (first
parameter equal to 1).
In this table each row represents a possible combination of +URAT, +COPS and +UREG values. Other
combinations are not possible.
4 GPRS connection
4.1 Context Activation
In order to use FTP, HTTP, SMTP and TCP/IP commands the following steps are necessary to establish a data
connection:
Command Response Description
AT+CGATT? +CGATT: 1 Check GPRS attach status.
Note: OK, the module is GPRS attached.
OK
Create a GPRS connection profile for TCP/IP with the
+UPSD command. This will be made in 2 steps:
1. Setup APN
2. Specify to use the dynamic IP address assignment
5 TCP/IP AT Commands
Before doing this example, verify that the module is registered on the network, and a GPRS connection is active.
Follow the steps in “Network Registration and Configuration” (chapter 3).
+UUSOLI indicates:
gggggggggggggggggggggggggg +CREG: 2 Module loses the network while writing data in data
prompt mode. If URC is enabled a URC is returned in
the byte stream.
In “Keep Alive” mode, the module periodically sends dummy TCP packets to prevent the network from
closing the inactive context. The network operator may close inactive TCP connections without
notification to the mobile.
First Scenario
Command Response Description
Remote server sends 2 data bytes on socket #0.
Second Scenario
Command Response Description
Third Scenario
Command Response Description
Remote server sends 30 data bytes on socket #0.
Remote server sent more data after the first part was
received. URC +UUSORD indicates the total amount of
data bytes stored the buffer after the last AT+USORD
execution. In this example 25 bytes are stored in the
buffer.
AT+USORD=0,10 +USORD: 0,10,"hfgbchs7[o" Only part of the data bytes (in this example 10 bytes)
OK are read.
AT+USORD=0,0 +USORD: 0,0 Verifies how much unread data is in the buffer. In this
OK example 0 bytes are in socket #0.
Fourth Scenario
Command Response Description
AT+USOWR=0,3 @ Request to write 3 data bytes into socket #0. Wait for
“@” symbol indicating the data prompt is now open.
123 +USOWR: 0,0 Write data. After the last byte the data prompt is
OK closed.
OK
+UUSOCL: 0 This URC indicates the TCP connection associated to
socket #0 is now closed and socket #0 is cleared.
OK
If the socket state is 7 it means a TCP connection
termination procedure is being performed.
By remote server
Command Response Description
+UUSOCL: 1 This URC indicates the TCP connection associated to
socket 1 is closed. Socket 1 is cleared.
By the module
Command Response Description
AT+USOCL=0 OK Socket closed by the module (socket #0).
For more details on “+++” escape sequence please refer to chapter 7.1.4.
If a context deactivation occurs open sockets become invalid. Close them and reinitialize TCP
connections.
6 UDP/IP AT Commands
6.1 Socket Write (+USOST)
Command Response Description
AT+USOCR=17 +USOCR: 0 Create a UDP socket. In this example Socket #0 is
OK created.
+UUSORD: 0,10
Remote host sends a UDP packet with 20 data bytes.
AT+USORF=0,10 +USORF: Read the remaining 10 data bytes of the previous
0,"151.9.34.66",454,2,"123456 packet. URC indicates 20 data bytes has been received
7890" and are still stored in the socket buffer.
OK
+UUSORD: 0,20 Note: after the first URC has been returned, a second
URC is returned (only after a reading operation)
indicating:
If a reading operation of a packet is not finished
it will be provided the remaining data of the
specific packet
Otherwise it will provide the number of data
bytes of packets stored in the socket buffer
If the UDP socket is not set in listening mode (see +USOLI) it won’t be possible to receive any packet if a
previous write operation is not performed.
Due to the UDP specific AT commands, this command should be considered obsolete and it is strongly
recommend avoiding its usage while working with UDP sockets. The command’s functionality for UDP
socket is maintained for backward compatibility only, please consider to use +USOST and +USORF
command instead of +USOCO with +USOWR and +USORD.
+UUSORD: 0,10
UDP packet with 20 byte of data received from
remote server.
AT+USORD=0,10 +USORD: 0,10,”1234567890” Read the remaining 10 data bytes of the previous
OK packet. URC indicates 20 data bytes has been received
and are still stored in the socket buffer.
+UUSORD: 0,20
Note: after the first URC has been returned, a second
URC is returned (only after a reading operation)
indicating:
If a reading operation of a packet is not finished
it will be provided the remaining data of the
specific packet
Otherwise it will provide the number of data
bytes of packets stored in the socket buffer
If the UDP socket is not set in listening mode (see +USOLI) it won’t be possible to receive any packet if a
previous write operation is not performed.
7 FTP AT Commands
Make sure to follow the steps in “Network Registration and Configuration” (chapter 3) before using the AT
commands in this chapter.
First do preliminary configuration:
1. Set verbose error messages
2. Check the PIN
3. Attach to the network
+UUFTPCR: 13,1
AT+UFTPC=10,"uploads" OK Create a new directory on the FTP server.
+UUFTPCR: 10,1
AT+UFTPC=13 OK Request again the file list.
+UUFTPCD: 13,258,"-rw-r--r--
1 ftp ftp 1037
Aug 5 09:45 dat_000
-rw-r--r-- 1 ftp ftp
21041 Aug 5 09:12 data.zip
drwxr-xr-x 2 ftp ftp
4096 Aug 5 09:48 uploads
-rw-r--r-- 1 ftp ftp
12 Aug 5 09:42 xlog.zip
"
+UUFTPCR: 13,1
Change directory to directory name "uploads".
AT+UFTPC=8,"uploads" OK Note: to return back in the parent directory use
+UUFTPCR: 8,1 AT+UFTPC=8,"..".
AT+UFTPC=5,"gps_positions","g OK Upload a file from the module to FTP server from local
ps_positions" +UUFTPCR: 5,1 file system of the module (in this example filename
“gps_positions”).
AT+UFTPC=13 OK Request the file list.
+UUFTPCD: 13,70,"-rw-r--r--
1 ftp ftp 176673
Aug 5 10:03 gps_positions"
+UUFTPCR: 13,1
AT+UFTPC=8,".." OK Return to the parent directory.
+UUFTPCR: 8,1
AT+UFTPC=4,"data.zip","data.z OK Download a file from the FTP server to the local file
ip" +UUFTPCR: 4,1 system of the module.
AT+UFTPC=0 OK Disconnect from FTP server.
+UUFTPCR: 0,1
AT+UPSDA=0,4 OK Detach the GPRS connection with the +UPSDA
command.
Note: the specified profile will be deactivated.
To list and view all files stored in the wireless module file system, refer to chapter 15.
time
T0 T1 T2 T3
T0 > TEPD: there must be at least TEPD seconds after the last data byte and the first escape character
T1 < TEPD: the second escape character must be sent within TEPD seconds after the first escape character
T2 < TEPD: the third escape character must be sent within T EPD seconds after the second escape character
T3 > TEPD: There must be at least TEPD seconds after the last escape character and the first AT command
8 SMTP AT Commands
Make sure to follow the steps in “Network Registration and Configuration” (chapter 3) before using the AT
commands in this chapter.
AT+USMTP=5,3600 OK
AT+UDNSRN=0, "smtp.mail.yahoo +UDNSRN:"69.147.102.58" Resolve the hostname.
.com" OK
AT+USMTPM=3,"This is the
subject of the email" OK 8. Set up the mail subject
9 HTTP AT Commands
Make sure to follow the steps in “Network Registration and Configuration” (chapter 3) before using the AT
commands in this chapter.
AT+UHTTP=0,4,80 OK
AT+UDNSRN=0, "www.test.neonse DNS resolution of www.test.neonseven.com.
ven.com" +UDNSRN: "151.9.34.66"
OK
To list and view all files stored in the wireless module file system, refer to chapter 15.
10 GPS AT Commands
Using AT-commands in this chapter can create / use several files on the local file system:
gps_profile (contains the GPS settings, e.g. AssistNow servers parameters)
xxxxxx.alp (almanac file for AssistNow Offline)
GPS_YYYYMMDD_nnn (GPS log on File System: YYYYMMDD is the date, nnn is an incremental index)
Before doing these examples, make sure the module is registered on the network. Follow the steps in “Network
Registration and Configuration” (chapter 3).
AT+UGPS=1,2 OK Start up the GPS with AssistNow Offline aiding (it will
download to file system the .alp field from the specified
server if there is no file on file system).
AT+UGPS=0 OK Stop the GPS.
Authentication for u-blox AssistNow Online Server (agps.u-blox.com) is done at the beginning of a server access
to the u-blox AssistNow server by sending the information listed below:
Exor of IMSI and IMEI
Home network code (not IMSI)
MCC, MNC, LAC, CI, TA of cell and neighboring cells used by the wireless module
Latency
After a successful (=GPS Fix OK) Assistance, the module provides the information below back to the server, for
quality monitoring purposes:
Exor of IMSI and IMEI
Calculated position after aiding
Position accuracy
Number of SV used
TTFF
13 GPIO AT Commands
Command Response Description
AT+CMEE=2 OK Set verbose error messages.
AT+UGPIOR=? +UGPIOR: (20, 21) GPIO pin numbers.
OK
For LEON GPIO1 is pin 20, GPIO2 is pin 21
For LUCY GPIO1 is pin 54, GPIO2 is pin 53, GPIO3 is
pin 41, GPIO4 is pin 39, GPIO5 is pin 31.
14 MUX AT Commands
There are 6 virtual channels for the MUX. CHANNEL 0 is used for the MUX control channel, Channels 1 to 5 can
be used for AT commands or GSM/GPRS data (note there can be only 1 data channel). GPS in tunneling mode
will use Channel #6.
AT+CMUX command has to be sent by the mux driver on host. When the control channel is closed the
mux is disabled. To close the mux channel it is necessary to stop the mux driver; after this the channel
#0 will not be seen as a virtual port.
OK
AT+ULSTFILE=1 +ULSTFILE: 1012131 Get free space in the file system (in bytes).
OK
AT+ULSTFILE=2,"a_file" +ULSTFILE: 24365 Get file size of “a_file” file (in bytes).
OK
AT+ULSTFILE=2,"some_name" +ULSTFILE: 0 If the specified file does not exist a 0 bytes dimension is
returned.
OK
AT+UDWNFILE="new_file",12 > Request the creation of a new file on file system
specifying file name and file size (in bytes).
Wait for “>” symbol indicating the data prompt is now
open (AT commands are not allowed in data prompt).
Hello World! OK Send to serial port the bytes to be written in the
specified file.
OK
Appendix
A List of Acronyms
Abbreviation / Term Explanation / Definition
3GPP 3rd Generation Partnership Project
CI Cell Identity
IP Internet Protocol
SV Satellite in View
TA Timing Advance
Related documents
[1] u-blox 2G GSM/GPRS AT Commands Manual, Docu. No GSM.G1-SW-09002 available on our
homepage (http://www.u-blox.com).
[2] 3GPP TS 27.010 - Terminal Equipment to User Equipment (TE-UE) multiplexer protocol (Release 1999)
[3] LEON-G100/G200 System Integration Manual, Docu. No. GSM.G1-HW-09002 available on our
homepage (http://www.u-blox.com).
[4] u-blox 3.5G HSDPA AT Commands Manual, Document No 3G.G1-SW-10000 available on our
homepage (http://www.u-blox.com)
For regular updates to u-blox documentation and to receive product change notifications please register
on our homepage.
Revision history
Revision Date Name Status / Comments
- 29/01/2009 fves Initial release
A 13/11/2009 lpah/sgod/tgri Changed order of chapters, update of List of Acronyms, added the
chapter HTTP AT commands and file system AT commands, update
of chapter 4 (TCP/IP AT Commands), added the chapter 8 (GPS AT
Commands), change of document status to “Preliminary”.
Contact
For complete contact information visit us at www.u-blox.com
u-blox Offices