Application
Simplify Communication
SIM7020 Series_TCPIP_Application Note
Version: 1.02
Release Date: December 27, 2018
Simplify Communication.
www.simcom.com
Simplify Communication
About Document
Document Information
SIM7020 Series_TCPIP_Application Note
1.02
Application Note
Released/Confidential
Document
Title
Version
Document Type
Document Status
Revision History
Revision Date
1.00
April 10, 2018
Owner
Xiaolun Wang
Status / Comments
First Release.
1.01
April 18, 2018
Albert Meng
Revised layout
1.02 Dec 27, 2018
Jiaxiang Wang
Modify and add chapter 4 about TCPIP Application
Jimmy Zhang
which compatible with SIM800 serial modules. Add
transparent mode
Related Documents
[1] SIM7020 Series AT Command Manual V1.02.pdf
This document applies to the following products:
Name
Size (mm)
Type
Comments
SIM7020E
SIM7020G
SIM7060G
NB1
NB2
NB2+GNSS
17.6*15.7
17.6*15.7
24*24
Band 1/3/5/8/20/28
Band 1/2/3/4/5/8/12/13/17/18/19/20/25/26/28/66/70/71
Band 1/2/3/4/5/8/12/13/17/18/19/20/25/26/28/66/70/71
Copyrights
This document contains proprietary technical information which is the property of SIMCom Wireless. Copying of this document
and giving it to others and the using or communication of the contents thereof, are forbidden without express authority.
Offenders are liable to the payment of damages. All rights reserved in the event of grant of a patent or the registration of a
utility model or design. All specification supplied herein are subject to change without notice at any time.
SIM7020 Series_TCPIP_Application Note Page 2 / 22
Simplify Communication
Contents
About Document ...................................................................................................................... 2
Document Information .............................................................................................................. 2
Revision History ......................................................................................................................... 2
Related Documents ................................................................................................................... 2
Contents ................................................................................................................................... 3
1
2
Purpose of this document ................................................................................................. 5
PDP Context Activation and Deactivation .......................................................................... 5
2.1
2.2
2.3
2.4
Auto-Activation ............................................................................................................. 5
APN Manual Configuration ............................................................................................ 5
DNS Parser and Ping ...................................................................................................... 6
Deactivation .................................................................................................................. 6
3
TCPIP Connection .............................................................................................................. 7
3.1
TCPIP Architecture ......................................................................................................... 7
3.2
TCP Client ...................................................................................................................... 7
3.3
UDP Connection ............................................................................................................ 7
3.4 Multiple Sockets ............................................................................................................ 8
Hex and ASCII Message ................................................................................................. 8
3.5
3.6
TCP ACK ......................................................................................................................... 8
3.7
Incoming Message Indication ........................................................................................ 9
3.8
3.9
3.10
Retention Scene when Module is Waked from PSM Mode ....................................... 9
Summary of Socket Error codes .................................................................................... 9
TCPIP Connection flow chart ....................................................................................... 10
4
TCPIP Application compatible with SIM800 serial module ................................................ 11
TCPIP Architecture ....................................................................................................... 11
4.1
TCP Client Connection ................................................................................................. 11
4.2
UDP Client Connection ................................................................................................ 12
4.3
UDP Extended Mode ................................................................................................... 12
4.4
4.5 Multi Connection......................................................................................................... 13
DNS Function ............................................................................................................... 14
4.6
4.7
Data Sending Related .................................................................................................. 14
Fixed Length Sending ....................................................................................... 14
4.7.1
SIM7020 Series_TCPIP_Application Note page3 / 22
Simplify Communication
4.8
4.8.1
4.8.2
4.7.2
4.7.3
4.7.4
Timed Sending ................................................................................................. 15
Select Data Transmitting Mode ....................................................................... 15
Query Data Transmitting Amount ................................................................... 15
Data Receiving Related ................................................................................................ 17
Receive Data Automatically ............................................................................. 17
Receive Data Manually .................................................................................... 17
GPRS States Exchange Related .................................................................................... 17
4.9
4.10 Connection Closing Related ........................................................................................ 19
Error Handling ............................................................................................................. 19
4.11
4.12
Transparent Mode ....................................................................................................... 19
4.12.1 What is Transparent Mode .............................................................................. 19
4.12.2 How to enable Transparent Mode .................................................................. 20
4.12.3 How to Establish Connection and Enter into Transparent Mode after Enable
Transparent Mode ........................................................................................................... 20
4.12.4 How to Switch Between Data Mode and Command Mode ............................ 20
Contact ................................................................................................................................... 22
SIM7020 Series_TCPIP_Application Note page4 / 22
Simplify Communication
1
Purpose of this document
Based on module AT command manual, this document will give an entire and complete concept
and TCPIP architecture introduction.
Developers could understand and develop application quickly and efficiently based on this
Document.
PDP Context Activation and Deactivation
2 Auto-Activation
2.1
AT Command
AT+CPIN?
AT+CSQ
AT+CGREG?
AT+CGACT?
AT+COPS?
AT+CGCONTRDP
Description
Check SIM card status
Check RF signal
Check PS service
Activated automatically
Check operator info
CHN-UNICOM is operator’s name9 is
NB-IOT network
Get APN and IP address from
network
Response
+CPIN:READY
OK
+CSQ: 20,0
OK
+CGREG: 0,1
OK
+CGACT: 1,1
OK
+COPS: 0,0,"CHN-UNICOM",9
OK
+CGCONTRDP:
1,5,"shnbiot","10.250.0.213.255.
255.255.0"
OK
2.2
APN Manual Configuration
AT Command
AT+CFUN=0
Response
+CPIN: NOT READY
OK
AT*MCGDEFCONT="IP","3GNET OK
Description
Disable RF
Configure new APN
SIM7020 Series_TCPIP_Application Note Page 5 / 22
"
AT+CFUN=1
AT+CGREG?
AT+CGCONTRDP
Simplify Communication
OK
+CPIN: READY
+CGREG: 0,1
OK
+CGCONTRDP:
1,5,"3GNET","10.250.0.253.255.255.255.0"
OK
Enable RF
Inquiry PS service
Attached PS domain and
got IP address
automatically
2.3
DNS Parser and Ping
AT Command
AT+CDNSGIP="www.baidu.com" OK
Response
AT+CIPPING="61.135.169.121"
+CDNSGIP:
1,"www.baidu.com","111.13.100.92"
OK
+CIPPING: 1,61.135.169.121,11,52
+CIPPING: 2,61.135.169.121,2,52
+CIPPING: 3,61.135.169.121,3,52
+CIPPING: 4,61.135.169.121,2,52
Description
Got Baidu host name’s
IP address using DNS
parser
Ping this IP address
2.4
Deactivation
AT Command
AT+CGACT=0,1
AT+CGACT?
AT+CGCONTRDP
Response
OK
+CGACT: 1,0
OK
OK
Description
Deactivate #1
Inquiry
#1
deactivated already
IP address is released
status,
it’s
SIM7020 Series_TCPIP_Application Note page6 / 22
Simplify Communication
TCPIP Connection
3
3.1
TCPIP Architecture
SIM7020 series modules support TCP client only. And the default socket interface is designed for
multiple sockets with total different 5 s, which could be TCP or UDP socket.
S
I
M
7
0
2
0
T
C
P
I
P
id=0
id=1
id=2
id=3
id=4
Serve
r
Cellular
Network
(Figure1 TCPIP Architecture)
3.2
TCP Client
AT Command
AT+CSOC=1,1,1
Response
+CSOC: 0
OK
AT+CSOCON=0,5245,"116.247.119.165" OK
OK
AT+CSOSEND=0,0,”Hello World”
AT+CSOCL=0
OK
3.3
UDP Connection
AT Command
AT+CSOC=1,2,1
Response
+CSOC: 0
OK
AT+CSOCON=0,5246,"116.247.119.165" OK
AT+CSOSEND=0,0,”Hello World”
OK
Description
Created one TCP socket,
=0
Connected remote TCP server
Send TCP data out
Close socket
Description
Created one UDP socket,
=0
Connected remote UDP peer
Send UDP data out
SIM7020 Series_TCPIP_Application Note page7 / 22
AT+CSOCL=0
3.4
Multiple Sockets
Simplify Communication
OK
Close socket
AT+CSOC=1,2,1
AT Command
AT+CSOC=1,1,1
Response
+CSOC: 0
OK
+CSOC: 1
OK
AT+CSOCON=0,5245,"116.247.119.165" OK
AT+CSOCON=1,5246,"116.247.119.165" OK
OK
AT+CSOSEND=0,0,”Hello World”
OK
AT+CSOSEND=1,10,”3132333435”
AT+CSOCL=0
OK
OK
AT+CSOCL=1
Description
Created one TCP socket, =0
Created one UDP socket, =1
Connected remote TCP server
Connected remote UDP peer
Send TCP data out
Send UDP data
Close socket 0
Close socket 1
3.5
Hex and ASCII Message
Command AT+CSOSEND=,, supports both Hex and Ascii code message. If
is pure hex, the parameter must be configured correct bytes and must be even
number.
Also Incoming message from remote socket are printed in Hex code.
3.6
TCP ACK
AT Command
AT+CSOC=1,1,1
AT+CSOSENDFLAG=1
AT+CSOCON=0,5245,"116.247.119.16
5"
AT+CSOSEND=0,0,”Hello World”
AT+CSOCL=0
Response
+CSOC:0
OK
OK
OK
OK
SEND: 0,11
OK
Description
Created one TCP socket, =0
Configure TCP ACK report
Connected remote TCP server
Send TCP data out, 11 bytes had been
sent out successfully.
Close socket
SIM7020 Series_TCPIP_Application Note page8 / 22