如果透传 TCPIP 连接 先发送+++返回 OK 后发送如下指令
+NETCLOSE: 0
//ensure GPRS network is available before
AT+CSQ
+CSQ: 23,0
OK
AT+CREG?
+CREG: 0,1
OK
AT+CPSI?
+CPSI: GSM,Online,460-00 0x1816,63905,81 EGSM 900,-68,0,31-31
OK
AT+CGREG?
+CGREG: 0,1
OK
//PDP Context Enable/Disable
APN setting:
AT+CGSOCKCONT=1,"IP","CMNET"
OK
AT+CSOCKSETPN=1
OK
Note, usually CSOCKAUTH and CSOCKSETPN parameter are kept default if not care about.
Enable PDP context:
AT+CIPMODE=0 // command mode, if not configured, it is 0 by default. If customers want
data mode, please configure before Net open.
OK
AT+NETOPEN
OK
+NETOPEN: 0
AT+IPADDR
+IPADDR: 10.113.43.157
OK
Disable PDP context:
AT+NETCLOSE
OK
+NETCLOSE: 0
//Command Mode
2.3.1 TCP Client
AT+CIPOPEN=0,"TCP","116.236.221.75",8011//only IP address is supported
OK
+CIPOPEN: 0,0
AT+CIPSEND=0,5
>HELLO
OK
+CIPSEND: 0,5,5
AT+CIPSEND=0, //the second parameter is empty which means using
end
>HELLO
OK
+CIPSEND: 0,5,5
AT+CIPCLOSE=0 // close by local
OK
+CIPCLOSE: 0,0
Note:
if connection closed by remote server, following URC will return:
+IPCLOSE: 0, 1
Here, the meaning of second parameter in this URC is as following,
0 - closed by local, active
1 - closed by remote, passive
3 - Reset
2.3.3 Extended Information
Command AT+CIPHEAD is used to show IP head (data length) information, and command
AT+CIPSRIP is used to show remote IP address and port once data are received.
AT+CIPHEAD=1
AT+CIPSRIP=0
AT+CIPOPEN=0,"TCP","116.236.221.75",8011
OK
+CIPOPEN: 0,0
AT+CIPSEND=0,5
>11111
OK
+CIPSEND: 0,5,5
// here, remote data is coming
+IPD13
hello from pc
AT+CIPSRIP=1
OK
// here, remote data is coming
RECV FROM:116.236.221.75:8011
+IPD15
hello from pc 2
AT+CIPCLOSE=0
OK
+CIPCLOSE: 0,0
2.3.5 Connection Status Checking
AT+CIPOPEN?
+CIPOPEN: 0
+CIPOPEN: 1
+CIPOPEN: 2
+CIPOPEN: 3
+CIPOPEN: 4
+CIPOPEN: 5
+CIPOPEN: 6
+CIPOPEN: 7
+CIPOPEN: 8
+CIPOPEN: 9
OK
AT+CIPOPEN=0,"TCP","116.236.221.75",8011
OK
+CIPOPEN: 0,0
+IPD15
hello from pc 3
AT+CIPOPEN?
+CIPOPEN: 0, "TCP","116.236.221.75",8011,-1 // last parameter of -1 indicates this
connection is active, this socket acts as a client
+CIPOPEN: 1
+CIPOPEN: 2
+CIPOPEN: 3
+CIPOPEN: 4
+CIPOPEN: 5
+CIPOPEN: 6
+CIPOPEN: 7
+CIPOPEN: 8
+CIPOPEN: 9
OK
2.4 Data Mode
2.4.1 TCP Client
AT+NETOPEN
OK
+NETOPEN: 0
AT+CIPOPEN=0,"TCP","116.236.221.75",8011//only
transparent mode.
CONNECT 115200
// sequence of +++ to quit data mode
OK
ATO // command ATO to quit command mode
CONNECT 115200
// sequence of +++ to quit data mode
OK
AT+CIPCLOSE=0
OK
CLOSED
+CIPCLOSE: 0,0
AT+NETCLOSE
OK
+NETCLOSE: 0
2.5 Switch between Data Mode and Command Mode
Hardware flow control is recommended.
Currently, USB->modem port, USB->AT port and UART port all support hardware flow control.
Software switching: escape sequence +++. Please take care, this is a complete command, do not
separate each character, also take care that the time delay before and after this sequence should be
more than 1000 milliseconds, the interval of each character should not be more than 900
milliseconds.
Hardware switching: DTR pin could be used to trigger data mode and command mode.Command
AT&D1 should be configured before application.
2 查询模块网络注册状态
AT+CPIN?
+CPIN: READY // 查询SIM 卡是否识别
OK
AT+CSQ
+CSQ: 27,99 // 查询信号强度
OK
AT+CNSMOD=1 // 设置模块网络制式状态自动上报功能
OK
AT+CNSMOD?
+CNSMOD: 0,8 // 查询模块注册网
络制式。8 表示注册在LTE 网络模式
OK
AT+CEREG?
+CEREG: 0,1 // 此时,表示可以
进行数据业务了。
OK
AT+CNSMOD?
+CNSMOD: 0,10 // 查询模块注册在非
LTE 网络下
OK
AT+CGREG?
+CGREG: 0,1 // 此时,表示可以进
行数据业务了。
OK
注意:在LTE 网络模式下,请使用AT+CEREG?判断模块数据是否可以使用。
如果是在其它网络模式下, 请使用AT+CGREG 判断模块数据是否可以使用。
参数2:返回1(或5)表示数据业务可以使用;返回2、3、4 表示数据业务不可
用。