Quectel BG96 TCP/IP Application Note
Quectel BG96 TCP/IP Application Note

Quectel BG96 TCP/IP Application Note

Lpwa module
Hide thumbs Also See for BG96 TCP/IP:
Table of Contents

Advertisement

Quick Links

BG96
Application Note
LPWA Module Series
Rev. BG96_TCP/IP_Application_Note_V1.2
Date: 2020-05-28
Status: Released
TCP/IP
www.quectel.com

Advertisement

Table of Contents
loading

Summary of Contents for Quectel BG96 TCP/IP

  • Page 1 BG96 TCP/IP Application Note LPWA Module Series Rev. BG96_TCP/IP_Application_Note_V1.2 Date: 2020-05-28 Status: Released www.quectel.com...
  • Page 2 QUECTEL OFFERS THE INFORMATION AS A SERVICE TO ITS CUSTOMERS. THE INFORMATION 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 ANY LIABILITY FOR ANY INJURY, LOSS OR DAMAGE OF ANY KIND INCURRED BY USE OF OR RELIANCE UPON THE INFORMATION.
  • Page 3: About The Document

    LPWA Module Series BG96 TCP/IP Application Note About the Document Revision History Version Date Author Description Walker HAN/ 2017-11-23 Initial Lucifer YAN Updated related information about the supported IPv6 feature of the module (Chapter 2.1.1, 2.1.2 and Justice HAN/ 2.1.15)
  • Page 4: Table Of Contents

    LPWA Module Series BG96 TCP/IP Application Note Contents About the Document ........................... 2 Contents ............................... 3 Table Index ..............................5 Introduction ............................6 1.1. The Process of Using TCP/IP AT Commands ................6 1.2. Description of Data Access Modes ....................8 TCP/IP AT Commands ........................
  • Page 5 LPWA Module Series BG96 TCP/IP Application Note 3.2.1. Set up a TCP Client Connection and Enter Buffer Access Mode ........36 3.2.2. Send Data in Buffer Access Mode ................. 37 3.2.3. Retrieve Data from Remote Server in Buffer Access Mode .......... 37 3.2.4.
  • Page 6 LPWA Module Series BG96 TCP/IP Application Note Table Index Table 1: Type of AT Commands and Responses ..................10 Table 2: Summary of Error Codes ......................49 Table 3: Terms and Abbreviations ......................51 BG96_TCP/IP_Application_Note 5 / 52...
  • Page 7: Introduction

    BG96 TCP/IP Application Note Introduction Quectel BG96 module features embedded TCP/IP stack, which enables the host to access the Internet directly over AT commands. This greatly reduces the dependence on the PPP and external TCP/IP protocol stacks and thus minimizes the cost.
  • Page 8 LPWA Module Series BG96 TCP/IP Application Note Power on the module Recommended Power on/off: 1. Power off: Send AT+QPOWD and then cut off power after 12 s or more. 2. Power on: Keep power key as low for Send AT command and wait for the module to respond OK 2 s, and then pull it to high.
  • Page 9: Description Of Data Access Modes

    LPWA Module Series BG96 TCP/IP Application Note 1.2. Description of Data Access Modes BG96 module supports the following three data access modes:  Buffer access mode  Direct push mode  Transparent access mode When opening a socket service via AT+QIOPEN, the data access mode can be specified by <access_mode>.
  • Page 10 LPWA Module Series BG96 TCP/IP Application Note NOTES In buffer access mode, if the buffer is not empty, the module will not report a new URC until all the received data has been read via AT+QIRD from buffer. In transparent access mode, AT commands cannot be executed. If the socket connection is closed because of network error or other errors, the module will report NO CARRIER and exit from the transparent access mode.
  • Page 11: Tcp/Ip At Commands

    LPWA Module Series BG96 TCP/IP Application Note TCP/IP AT Commands 2.1. AT Command Syntax 2.1.1. Definitions  <CR> Carriage return character.  <LF> Line feed character.  <...> Parameter name. Angle brackets do not appear on command line.  [...] Optional parameter of a command or an optional part of TA information response.
  • Page 12: Description Of Tcp/Ip At Commands

    LPWA Module Series BG96 TCP/IP Application Note 2.2. Description of TCP/IP AT Commands 2.2.1. AT+QICSGP Configure Parameters of a TCP/IP Context The Write Command configures <APN>, <username>, <password> and other parameters of a TCP/IP context. AT+QICSGP Configure Parameters of a TCP/IP Context...
  • Page 13: At+Qiact Activate A Pdp Context

    LPWA Module Series BG96 TCP/IP Application Note <password> String type. Password. <authentication> Integer type. Authentication methods. None CHAP PAP or CHAP Example AT+QICSGP=1 //Query the configuration of context 1. +QICSGP: 1,"","","",0 AT+QICSGP=1,1,"UNINET","","",1 //Configure context 1. APN is "UNINET" for China Unicom.
  • Page 14: At+Qideact Deactivate A Pdp Context

    LPWA Module Series BG96 TCP/IP Application Note If there is any error: ERROR Maximum Response Time 150 s, determined by network. Characteristics Parameter <contextID> Integer type. Context ID. Range: 1–16. <context_state> Integer type. Context state. Deactivated Activated <context_type> Integer type. Protocol type.
  • Page 15: At+Qiopen Open A Socket Service

    LPWA Module Series BG96 TCP/IP Application Note Parameter <contextID> Integer type. Context ID. Range: 1–16. 2.2.4. AT+QIOPEN Open a Socket Service The Write Command opens a socket service. The service type can be specified by <service_type>. The data access mode (buffer access mode, direct push mode and transparent access mode) can be specified by <access_mode>.
  • Page 16 LPWA Module Series BG96 TCP/IP Application Note If there is any error: ERROR Error description can be got via AT+QIGETERROR. If <access_mode>=0 or 1: +QIOPEN: <connectID>,<err> <err> is 0 when the service is opened successfully. In other cases, <err> is not 0.
  • Page 17: At+Qiclose Close A Socket Service

    LPWA Module Series BG96 TCP/IP Application Note 2.2.5. AT+QICLOSE Close a Socket Service The Write Command closes a specified socket service. Depending on the network, it will take at most 10 seconds (default value, can be configured by <timeout>) to return OK or ERROR after executing AT+QICLOSE.
  • Page 18 LPWA Module Series BG96 TCP/IP Application Note emote_port>,<local_port>,<socket_state>,<contextID>,<s erverID>,<access_mode>,<AT_port> […] Write Command Response Return the status of all existing connections in a specified If <query_type> is 0, query the connection status of a specified context context: AT+QISTATE=<query_type>,<context +QISTATE: <connectID>,<service_type>,<IP_address>,<r ID>...
  • Page 19: At+Qisend Send Data

    LPWA Module Series BG96 TCP/IP Application Note If <service_type>="TCP" or "UDP", it is the port of remote server. If <service_type>="TCP LISTENER" or "UDP SERVICE", the port is invalid. If <service_type>="TCP INCOMING", it is the port of remote client. <local_port> Integer type. Local port number. Range: 0–65535.
  • Page 20 LPWA Module Series BG96 TCP/IP Application Note If the connection is established and the data is sent AT+QISEND=<connectID> successfully: SEND OK If the connection is established but the sending buffer is full: SEND FAIL If the connection is not established, abnormally closed, or any...
  • Page 21: At+Qird Retrieve The Received Tcp/Ip Data

    LPWA Module Series BG96 TCP/IP Application Note Write Command Response When <send_length> is 0, query the If the specified <connectID> connection exists: sent data +QISEND: <total_send_length>,<ackedbytes>,<unackedb AT+QISEND=<connectID>,0 ytes> If there is any error: ERROR Maximum Response Time 120 s, determined by network.
  • Page 22 LPWA Module Series BG96 TCP/IP Application Note "UDP" or "TCP INCOMING" +QIRD: <read_actual_length><CR><LF><data> AT+QIRD=<connectID>[,<read_length >] If there is no data: +QIRD: 0 If the connection does not exist: ERROR Write Command Response When <service_type> is "UDP If the data exists: SERVICE"...
  • Page 23: At+Qisendex Send Hex String Data

    LPWA Module Series BG96 TCP/IP Application Note Default value: 1500. Unit: byte. <read_actual_length> Integer type. Length of the data that has been actually retrieved. Unit: byte. <remoteIP> String type. Remote IP address. It is only valid when <service_type> is "UDP SERVICE".
  • Page 24: At+Qiswtmd Switch Data Access Mode

    LPWA Module Series BG96 TCP/IP Application Note 2.2.10. AT+QISWTMD Switch Data Access Mode The Write Command switches data access mode between buffer access mode, direct push mode and transparent access mode. When starting a socket service, the data access mode can be specified by <access_mode>...
  • Page 25 LPWA Module Series BG96 TCP/IP Application Note AT+QPING Ping a Remote Server Test Command Response AT+QPING=? +QPING: (range of supported <connectID>s),<host>,(range of supported <timeout>s),(range of supported <pingnum>s) Write Command Response AT+QPING=<contextID>,<host>[,<tim If a remote server is pinged successfully: eout>[,<pingnum>]] +QPING: <result>[,<IP_address>,<bytes>,<time>,<ttl>]<C R><LF>[…]...
  • Page 26: At+Qntp Synchronize Local Time With Ntp Server

    LPWA Module Series BG96 TCP/IP Application Note Others Error code of operation. Please refer to the error codes in Chapter 4. <sent> Integer type. Total number of sending the ping requests. <rcvd> Integer type. Total number of the ping requests that received the response.
  • Page 27: At+Qidnscfg Configure Address Of Dns Server

    LPWA Module Series BG96 TCP/IP Application Note <port> Integer type. Port number of NTP server. Range: 1-65535. Default value: 123. <auto_set_time> Integer type. Whether to automatically set synchronized time to local time. Not set <err> Integer type. Error code of operation. Please refer to Chapter 4.
  • Page 28: At+Qidnsgip Get Ip Address By Domain Name

    LPWA Module Series BG96 TCP/IP Application Note 2.2.14. AT+QIDNSGIP Get IP Address by Domain Name Before querying the DNS, the 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.
  • Page 29 LPWA Module Series BG96 TCP/IP Application Note +QICFG: "dataformat",(list of supported <send_data_format> s),(list of supported <recv_data_format>s) +QICFG: "viewmode",(list of supported <view_mode>s) +QICFG: "recvind",(list of supported <recv_ind>s) +QICFG: "prefix",<IPv6_prefix>,(list of supported <prefix_len gth>s) +QICFG: "tcp/retranscfg",(range of supported <max_backoff s>s),(range of supported <max_rto>s) +QICFG: "tcp/keepalive",(list of supported <keepalive>s),(ran...
  • Page 30 LPWA Module Series BG96 TCP/IP Application Note _data_format>,<recv_data_form If the optional parameters are specified, set the format for the data at>] to be sent and received: If there is any error: ERROR Write Command Response Query/set the output format of...
  • Page 31 LPWA Module Series BG96 TCP/IP Application Note number +QICFG: "tcp/retranscfg",<max_backoffs>,<max_rto> retransmission AT+QICFG="tcp/retranscfg"[,<m ax_backoffs>,<max_rto>] If the optional parameters are specified, set the maximum interval and the number of TCP retransmission: If there is any error: ERROR Write Command Response Query/set whether to enable TCP...
  • Page 32 LPWA Module Series BG96 TCP/IP Application Note Parameter <transpkt_size> Integer type. Maximum length of the data packet to be sent. Range: 1-1460. Default value: 1024. Unit: byte. <transwaittm> Integer type. In transparent access mode, if the length of data received from the port is less than the value specified by <transpkt_size>, after exceeding...
  • Page 33: At+Qisde Control Whether To Echo The Data For At+Qisend

    LPWA Module Series BG96 TCP/IP Application Note 2.2.16. AT+QISDE Control Whether to Echo the Data for AT+QISEND The Write Command controls whether to echo the data for AT+QISEND. AT+QISDE Control Whether to Echo the Data for AT+QISEND Test Command Response AT+QISDE=? +QISDE: (list of supported <echo>s)
  • Page 34: Description Of Urcs

    LPWA Module Series BG96 TCP/IP Application Note Maximum Response Time 300 ms Characteristics Parameter <err> Integer type. Error code of operation. Please refer to Chapter 4. <errcode_description> A string parameter indicates the details of error information. Please refer to Chapter 4 for details.
  • Page 35: Qiurc: "Incoming Full" Indicate Incoming Connection Full

    LPWA Module Series BG96 TCP/IP Application Note In direct push mode, the received data will be outputted to COM port directly. +QIURC: "recv" Indicate Incoming Data +QIURC: "recv",<connectID> Indicate incoming data in buffer access mode. The host can retrieve data via AT+QIRD.
  • Page 36: Qiurc: "Pdpdeact" Indicate Pdp Deactivation

    LPWA Module Series BG96 TCP/IP Application Note Parameter <connectID> Integer type. Assign this socket service for the incoming connection, which is automatically specified by the module. Range: 0–11. <serverID> Integer type. The incoming <connectID> accepted by the server whose <service_type> is "TCP LISTENER" and listening socket ID is <serverID>.
  • Page 37: Examples

    LPWA Module Series BG96 TCP/IP Application Note Examples 3.1. Configure and Activate a Context 3.1.1. Configure a Context AT+QICSGP=1,1,"UNINET","","",1 //Configure context 1. APN is "UNINET" for China Unicom. 3.1.2. Activate a Context AT+QIACT=1 //Activate context 1. Depending on the network, the maximum response time is 150 s.
  • Page 38: Send Data In Buffer Access Mode

    LPWA Module Series BG96 TCP/IP Application Note +QIOPEN: 0,0 //TCP client is connected successfully. It is suggested to wait for 150 seconds for the URC +QIOPEN: <connectID>,<err>. If the URC cannot be received in 150 seconds, the host can use AT+QICLOSE to close the socket.
  • Page 39: Close A Connection

    LPWA Module Series BG96 TCP/IP Application Note +QIRD: 5 //The length of actually retrieved data is 5 bytes. test1 AT+QIRD=0,1500 +QIRD: 0 //No data in buffer. AT+QIRD=0,0 //Query the total length of received data, including read and unread data. +QIRD: 5,5,0 3.2.4.
  • Page 40: Send Data In Buffer Access Mode

    LPWA Module Series BG96 TCP/IP Application Note 3.3.2. Send Data in Buffer Access Mode AT+QISEND=0 //Send variable-length data. >test1<ctrl+Z> SEND OK //SEND OK does not mean the data has been sent to the server successfully. The host can query whether the data has reached the server via AT+QISEND=0,0.
  • Page 41: Close A Connection

    LPWA Module Series BG96 TCP/IP Application Note 3.3.4. Close a Connection AT+QICLOSE=0 //Close a connection whose <connectID> is 0. Depending on the network, the maximum response time is 10 seconds. 3.4. TCP Client Works in Transparent Access Mode 3.4.1. Set up a TCP Client Connection and Enter Transparent Access Mode AT+QIOPEN=1,0,"TCP","220.180.239.212",8009,0,2...
  • Page 42: Tcp Client Works In Direct Push Mode

    LPWA Module Series BG96 TCP/IP Application Note 3.5. TCP Client Works in Direct Push Mode 3.5.1. Set up a TCP Client Connection and Enter Direct Push Mode AT+QIOPEN=1,0,"TCP","220.180.239.212",8009,0,1 //Context is 1 and <connectID> is 0. Before using AT+QIOPEN, the host should activate the context via AT+QIACT first.
  • Page 43: Close A Tcp Client

    LPWA Module Series BG96 TCP/IP Application Note 3.5.4. Close a TCP Client AT+QICLOSE=0 //Close the connection whose <connectID> is 0. Depending on the network, the maximum response time is 10 seconds. 3.6. TCP Server Works in Buffer Access Mode under IPv4 3.6.1.
  • Page 44: Close A Tcp Server

    LPWA Module Series BG96 TCP/IP Application Note AT+QIRD=11,0 //Query the total length of retrieved data, including read and unread data. +QIRD: 4,4,0 3.6.4. Close a TCP Server AT+QICLOSE=11 //Close the incoming connection. Depending on the network, the maximum response time is 10 seconds.
  • Page 45: Receive Data From Incoming Connection

    LPWA Module Series BG96 TCP/IP Application Note 3.7.3. Receive Data from Incoming Connection +QIURC: "recv",11 //Receive data from remote incoming connection. AT+QIRD=11,1500 //Retrieve data received from incoming connection. +QIRD: 4 //Actually retrieved data length is 4 bytes. test AT+QIRD=11,1500 +QIRD: 0 //No data in buffer.
  • Page 46: Send Udp Data To Remote

    LPWA Module Series BG96 TCP/IP Application Note +QISTATE: 2,"UDP SERVICE","10.7.157.1",0,3030,2,1,2,0,"usbmodem" 3.8.2. Send UDP Data to Remote AT+QISEND=2,10,"10.7.89.10",6969 //Send 10 bytes data to remote whose IP is 10.7.89.10 and remote port is 6969. >1234567890 SEND OK 3.8.3. Receive Data from Remote +QIURC: "recv",2...
  • Page 47: Udp Service Under Ipv6

    LPWA Module Series BG96 TCP/IP Application Note 3.9. UDP Service under IPv6 3.9.1. Start a UDP Service AT+QIOPEN=1,2,"UDP SERVICE","0:0:0:0:0:0:0:1",0,12345,0 //Start a UDP service, <connectID> is 2 and <context> is 1. Before using AT+QIOPEN, the host should activate the context with AT+QIACT first.
  • Page 48: Ping A Remote Server

    LPWA Module Series BG96 TCP/IP Application Note 3.10. Ping a Remote Server AT+QPING=1,"www.baidu.com" //Ping www.baidu.com in context 1. Before pinging the destination IP address, the host should activate the context by AT+QIACT first. +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 AT+QPING=1,"2001:468:2100:1:0:0:0:0"...
  • Page 49: Get Last Error Code

    LPWA Module Series BG96 TCP/IP Application Note +QNTP: 0,"2013/08/19,11:10:10+32" AT+CCLK? +CCLK: "13/08/19,11:10:57+32" 3.12. Get Last Error Code AT+QIOPEN=1,"TCP","220.180.239.212",8009,0,1 //Start a socket service, but <connectID> is not specified. ERROR AT+QIGETERROR +QIGETERROR: 552, invalid parameters BG96_TCP/IP_Application_Note 48 / 52...
  • Page 50: Summary Of Error Codes

    LPWA Module Series BG96 TCP/IP Application Note Summary of Error Codes If <err> is returned after executing TCP/IP AT commands, the details of error can be queried via AT+QIGETERROR. Please note that AT+QIGETERROR just returns error code of the last TCP/IP AT command.
  • Page 51 LPWA Module Series BG96 TCP/IP Application Note DNS parse failed Socket connect failed Socket has been closed Operation busy Operation timeout PDP context broken down Cancel send Operation not allowed APN not configured Port busy BG96_TCP/IP_Application_Note 50 / 52...
  • Page 52: Appendix A Reference

    LPWA Module Series BG96 TCP/IP Application Note Appendix A Reference Table 3: Terms and Abbreviations Abbreviation Description 3GPP 3rd Generation Partnership Project Acknowledge Access Point Name CHAP Challenge Handshake Authentication Protocol Domain Name System Finish Identify Internet Protocol IPv4 Internet Protocol Version 4...
  • Page 53 LPWA Module Series BG96 TCP/IP Application Note Unsolicited Result Code Universal Serial Bus Coordinated Universal Time BG96_TCP/IP_Application_Note 52 / 52...

Table of Contents