Quectel BG95 Series Application Note
Hide thumbs Also See for BG95 Series:
Table of Contents

Advertisement

BG95&BG77&BG600L Series
TCP/IP Application Note
LPWA Module Series
Version: 1.1
Date: 2021-03-29
Status: Released

Advertisement

Table of Contents
loading

Summary of Contents for Quectel BG95 Series

  • Page 1 BG95&BG77&BG600L Series TCP/IP Application Note LPWA Module Series Version: 1.1 Date: 2021-03-29 Status: Released...
  • Page 2 To the maximum extent permitted by law, Quectel excludes all liability for any loss or damage suffered in connection with the use of the functions and features under development, regardless of whether such loss or damage may have been foreseeable.
  • Page 3 BG95&BG77&BG600L Series TCP/IP Application Note Copyright The information contained here is proprietary technical information of Quectel. Transmitting, reproducing, disseminating and editing this document as well as using the content without permission are forbidden. 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.
  • Page 4: About The Document

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note About the Document Revision History Version Date Author Description 2019-08-12 Terrence YANG Initial 1. Added an applicable module BG600L-M3. 2. Updated the valid value range of <timeout> in AT+QICLOSE from 1–65535 to 0–65535 (Chapter 2.3.5).
  • Page 5: Table Of Contents

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Contents About the Document ........................... 3 Contents ............................... 4 Table Index ..............................7 Introduction ............................8 1.1. Applicable Modules ........................8 1.2. Usage of TCP/IP AT Commands ....................9 1.3. Description of Data Access Modes .................... 11 TCP/IP AT Commands ........................
  • Page 6 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 3.1.3. Deactivate a Context ...................... 39 3.2. TCP Client Works in Buffer Access Mode under IPv4 ............... 39 3.2.1. Set up a TCP Client Connection and Enter Buffer Access Mode ........39 3.2.2.
  • Page 7 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 3.10.3. Close a UDP Client ....................50 3.11. PING ............................51 3.12. Synchronize Local Time ......................51 3.13. Getting the Last Error Code ....................... 52 Summary of Result Codes ........................ 53 Appendix A References ........................55 BG95&BG77&BG600L_Series_TCP/IP_Application_Note 6 / 56...
  • Page 8 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Table Index Table 1: Applicable Modules ......................... 8 Table 2: Types of AT Commands ....................... 13 Table 3: Summary of Result Codes ......................53 Table 4: Related Document ........................55 Table 5: Terms and Abbreviations ......................55 BG95&BG77&BG600L_Series_TCP/IP_Application_Note 7 / 56...
  • Page 9: Introduction

    BG95&BG77&BG600L Series TCP/IP Application Note Introduction Quectel BG95 series, BG77 and BG600L-M3 modules feature an embedded TCP/IP stack, which enables the host to access the Internet directly via AT commands. This greatly reduces the dependence on external PPP and TCP/IP protocol stacks and thus minimizes the cost.
  • Page 10: Usage Of Tcp/Ip At Commands

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note NOTE See the firmware release notes of corresponding module models to check whether the function has been supported. 1.2. Usage of TCP/IP AT Commands Through TCP/IP AT commands, the host can configure a PDP context, activate/deactivate the PDP context, open/close a socket service and send/retrieve data via the socket service.
  • Page 11 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Power on the module Recommended Power on/off: 1. Power off: Send AT+QPOWD first. After 12 s or more, cut off the power supply. 2. Power on: Keep PWRKEY as low for Send AT command and wait for the module to respond OK 2 s, and then pull it to high.
  • Page 12: Description Of Data Access Modes

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 1.3. Description of Data Access Modes The modules support three data access modes:  Buffer access mode  Direct push mode  Transparent transmission mode When opening a socket service with AT+QIOPEN, you can specify the data access mode by <access_mode>.
  • Page 13 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note the data access mode back to transparent transmission mode. When transparent transmission mode is entered successfully, CONNECT is returned. If no connection has entered transparent transmission mode before, ATO returns NO CARRIER. NOTES In buffer access mode, if the buffer is not empty, the module does not report a new URC until all the received data has been read with AT+QIRD from the buffer.
  • Page 14: Tcp/Ip At Commands

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note TCP/IP AT Commands 2.1. AT Command Introduction 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 15: Declaration Of At Command Examples

    The AT command examples in this document are provided to help you familiarize with AT commands and learn how to use them. The examples, however, should not be taken as Quectel’s recommendation or suggestions about how you should design a program flow or what status you should set the module into.
  • Page 16: At+Qiact Activate A Pdp Context

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Parameter Integer type. Context ID. Range: 1–16. <contextID> Integer type. Protocol type. <context_type> IPv4 IPv6 IPv4v6 String type. Access Point Name. <APN> String type. Username. <username> String type. Password. <password> Integer type. Authentication methods. <authentication>...
  • Page 17: At+Qideact Deactivate A Pdp Context

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Read command Response Return the list of the currently activated contexts and their IP AT+QIACT? addresses: +QIACT: 1,<context_state>,<context_type>[,<IP_addres s>] [..+QIACT: 16,<context_state>,<context_type>[,<IP_addres s>]] Write Command Response Activate a specified PDP context AT+QIACT=<contextID> ERROR Maximum Response Time 150 s, determined by the network.
  • Page 18: At+Qiopen Open A Socket Service

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note AT+QIDEACT=<contextID> ERROR Maximum Response Time 40 seconds, determined by the network. Characteristics Parameter <contextID> Integer type. Context ID. Range: 1–16. 2.3.4. AT+QIOPEN Open a Socket Service This 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 transmission mode) can be specified by <access_mode>.
  • Page 19 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note SERVICE","<IP_address>/<domain_name>",(range supported <remote_port>s),(range supported <local_port>s),(range of supported <access_mode>s) Write Command Response AT+QIOPEN=<contextID>,<connectI If in transparent transmission mode (<access_mode>=2) and the service is opened successfully: D>,<service_type>,<IP_address>/<d omain_name>,<remote_port>[,<local CONNECT _port>[,<access_mode>]] If there is any error: ERROR Error description can be got via AT+QIGETERROR.
  • Page 20: At+Qiclose Close A Socket Service

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note If <service_type> is "TCP LISTENER" or "UDP SERVICE", specify this parameter as 0. <local_port> Integer type. Local port number. Range: 0–65535. If <service_type> is "TCP LISTENER" or "UDP SERVICE", this parameter must be specified.
  • Page 21: At+Qistate Query Socket Service Status

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Parameter Integer type. Socket service index. Range: 0–11. <connectID> Integer type. Timeout value for the response to be outputted. If the FIN ACK of the <timeout> other peer is not received within <timeout>, the module will be forced to close the socket.
  • Page 22 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Parameter Integer type. Query type. <query_type> Query connection status of all socket services in a specified context Query connection status of a specified socket service <contextID> Integer type. Context ID. Range: 1–16. <connectID>...
  • Page 23: At+Qisend Send Data

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 2.3.7. AT+QISEND Send Data In buffer access mode (<access_mode>=0) or direct push mode (<access_mode>=1), the data can be sent with AT+QISEND. If the data is sent to the module successfully, SEND OK is returned. Otherwise SEND FAIL or ERROR is returned.
  • Page 24 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note If the connection is not established, abnormally closed, or any parameter is incorrect: ERROR Write Command Response Send fixed length data to specified remote IP address and When <service_type> "UDP SERVICE" remote port. The <service_type> must be "UDP SERVICE". AT+QISEND=<connectID>,<send_len >...
  • Page 25: At+Qird Retrieve The Received Tcp/Ip Data

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note SERVICE". <total_send_length> Integer type. Total length of sent data. Unit: byte. <ackedbytes> Integer type. Total length of acknowledged data. Unit: byte. <unackedbytes> Integer type. Total length of unacknowledged data. Unit: byte. 2.3.8. AT+QIRD Retrieve the Received TCP/IP Data In buffer access mode, after receiving data, the module buffers it and reports +QIURC: "recv",<connectID>[,<data_len>], then the data can be retrieved with AT+QIRD.
  • Page 26: At+Qisendex Send Hex String Data

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note If the connection does not exist: ERROR Write Command Response When <read_length> is 0, query the If the specified connection exists: retrieved data length +QIRD: <total_receive_length>,<have_read_length>,<unr AT+QIRD=<connectID>,0 ead_length> If there is any error: ERROR Maximum Response Time 120 s, determined by network.
  • Page 27: At+Qiswtmd Switch Data Access Mode

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Write Command Response If the hex string is sent successfully: AT+QISENDEX=<connectID>,< hex_string>[,<RAI_info>] SEND OK If the sending buffer is full: SEND FAIL If the connection does not exist: ERROR Maximum Response Time 120 s, determined by network.
  • Page 28: At+Qping Ping A Remote Host

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note AT+QISWTMD Switch Data Access Mode Test Command Response AT+QISWTMD=? +QISWTMD: (range of supported <connectID>s),(range of supported <access_mode>s) Write Command Response AT+QISWTMD=<connectID>,<access If <access_mode> is 0 or 1, and data access mode is _mode>...
  • Page 29 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Write Command Response AT+QPING=<contextID>,<host>[,<ti If a remote host is pinged successfully: meout>[,<pingnum>]] +QPING: <ping_result>[,<IP_address>,<bytes>,<time>,< TTL>] […] +QPING: <finresult>[,<sent>,<rcvd>,<lost>,<min>,<ma x>,<avg>] If there is any error: ERROR Maximum Response Time 300 s Characteristics Parameter <contextID>...
  • Page 30: At+Qntp Synchronize Local Time With Ntp Server

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note <lost> Integer type. Total number of the ping requests that are time out. <min> Integer type. Minimum response time. Unit: ms. <max> Integer type. Maximum response time. Unit: ms. <avg> Integer type. Average response time. Unit: ms. 2.3.12.
  • Page 31: At+Qidnscfg Configure Address Of Dns Server

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note <result> Integer type. Result code of the operation. See Chapter 4 for details. <time> String type. The time synchronized from NTP server. The format is "YYYY/MM/DD,hh:mm:sszz". Range of "zz": -48 to 56. 2.3.13.
  • Page 32: At+Qicfg Configure Optional Parameters

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note AT+QIDNSGIP Get IP Address by Domain Name Test Command Response AT+QIDNSGIP=? +QIDNSGIP: (range of supported <contextID>s),<host_name> Write Command Response AT+QIDNSGIP=<contextID>,<ho st_name> +QIURC: "dnsgip",<result>,<IP_count> <DNS_ttl> [..+QIURC: "dnsgip",<host_IP_addr>] If there is any error: ERROR Maximum Response Time 60 s, determined by the network.
  • Page 33 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note <interval_time>s),(range of supported <probe_cnt>>s) +QICFG: "tcp/retranscfg",(range supported <max_backoffs>s),(range of supported <max_rto>s) Write Command Response Query/set the packet size for If the optional parameter is omitted, query the current setting: transparent transmission mode +QICFG: "transpktsize",<transpkt_size>...
  • Page 34 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note mode>] If the optional parameter is specified, set the output format of received data: ERROR Write Command Response Query/set the URC format in buffer If the optional parameter is omitted, query the current setting: access mode.
  • Page 35 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note ax_backoffs>,<max_rto>] If the optional parameters are specified, set the maximum interval and the number of TCP retransmission: ERROR Maximum Response Time 300ms The command takes effect immediately. Characteristics The configuration is not saved. Parameter <transpkt_size>...
  • Page 36: At+Qisde Control Whether To Echo The Data For At+Qisend

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note <max_rto> Integer type. Maximum interval between TCP retransmissions. Range: 5–1000. Default value: 600. Unit: 100 ms. NOTE The settings of AT+QICFG="tcp/retranscfg",<max_backoffs>,<max_rto> and AT+QICFG="tcp/kee palive",<keepalive>,<idle_time>,<interval_time>,<probe_cnt> take effect to all TCP sockets. 2.3.16. AT+QISDE Control Whether to Echo the Data for AT+QISEND This command controls whether to echo the data for AT+QISEND.
  • Page 37: Description Of Urcs

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note AT+QIGETERROR Query the Last Error Code Test command Response AT+QIGETERROR=? Execution Command Response AT+QIGETERROR +QIGETERROR: <result>,<result_code_description> Maximum Response Time 300 ms Characteristics Parameter <result> Integer type. Result code of the operation. See Chapter 4 for details. <result_code_description>...
  • Page 38: Qiurc: "Recv" Indicate Incoming Data

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 2.4.2. +QIURC: "recv" Indicate Incoming Data In buffer access mode or direct push mode, after receiving data, the module reports a URC to the host. buffer access mode, after receiving data, module reports +QIURC: "recv",<connectID>[,<data_len>] to notify the host.
  • Page 39: Qiurc: "Pdpdeact" Indicate Pdp Deactivation

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note In this case, the module reports +QIURC: "incoming". The <service_type> of the new connection will be “TCP INCOMING”, and the <access_mode> will be buffer access mode. +QIURC: "incoming" Indicate Incoming Connection When the new incoming connection is accepted by +QIURC: "incoming",<connectID>,<s erverID>,<remoteIP>,<remote_port>...
  • Page 40: Examples

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Examples 3.1. Configure and Activate a Context 3.1.1. Configure a Context AT+QICSGP=1,1,"CMNBIOT","","",1 //Configure context 1. APN is "CMNBIOT" for China Mobile NB-IoT network. 3.1.2. Activate a Context AT+QIACT=1 //Activate context 1. Depending on the network, the maximum response time is 150 s.
  • Page 41: Send Data In Buffer Access Mode

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

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 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. Close a Connection AT+QICLOSE=0 //Close a connection whose <connectID> is 0. Depending on the network, the maximum response time is 10s.
  • Page 43: Receive Data From Remote Server In Buffer Access Mode

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note successfully. The host can query whether the data has reached the server with AT+QISEND=0,0. AT+QISEND=0,4 //Send fixed-length data and the data length is 4 bytes. >test SEND OK AT+QISEND=0,0 //Query the length of sent data, acknowledged data and unacknowledged data.
  • Page 44: Tcp Client Works In Transparent Transmission Mode

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 3.4. TCP Client Works in Transparent Transmission Mode 3.4.1. Set up a TCP Client Connection and Enter Transparent Transmission Mode //Context is 1 and <connectID> is 0. Before using AT+QIOPEN, the host should activate the context with AT+QIACT first.
  • Page 45: Send Data In Direct Push Mode

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note +QIOPEN: 0,0 //TCP client connected successfully. It is suggested to wait for 150 seconds for the URC +QIOPEN: <connectID>,<result>. If the URC cannot be received in 150 seconds, the host could use AT+QICLOSE to close the socket.
  • Page 46: Tcp Server Works In Buffer Access Mode Under Ipv4 Network

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 3.6. TCP Server Works in Buffer Access Mode under IPv4 Network 3.6.1. Start a TCP Server //Context is 1 and <connectID> is 1. Before using AT+QIOPEN, the host should activate the context with AT+QIACT first.
  • Page 47: Close A Tcp Server

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 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. AT+QICLOSE=1 //Close TCP server listening. 3.7. TCP Server Works in Buffer Access Mode under IPv6 Network 3.7.1.
  • Page 48: Switch Incoming Connection To Transparent Transmission Mode

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note AT+QIRD=11,0 //Query the total length of received data, including read and unread data. +QIRD: 4,4,0 3.7.4. Switch Incoming Connection to Transparent Transmission Mode AT+QSWTMD=11,2 //Switch the incoming connection whose socket service index is 11 to transparent transmission mode. CONNECT 1234567890 //Send data directly.
  • Page 49: Send Udp Data To Remote Client

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 3.8.2. Send UDP Data to Remote Client AT+QISEND=2,10,"10.7.89.10",6969 //Send 10 bytes data to a remote client whose IP is 10.7.89.10 and the port is 6969. >1234567890 SEND OK 3.8.3. Retrieve Data from Remote Client +QIURC: "recv",2 //Received data from the remote client.
  • Page 50: Send Udp Data To Remote Client

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note +QIOPEN: 2,0 //UDP service is opened successfully. AT+QISTATE=0,1 //Query the connection status of context 1. +QISTATE: 2,"UDP SERVICE","2001:468:2100:1:2001:468:2100:1",0,12345,2,1,2,0,"usbmodem" 3.9.2. Send UDP Data to Remote Client AT+QISEND=2,10,"2001:468:2100:1:0:0:0:0",5001 //Send 10 bytes data to a remote client whose IP is 2001:468:2100:1:0:0:0:0 and the port is 5001.
  • Page 51: Send Udp Data With Rai Information

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 3.10.2. Send UDP Data with RAI Information AT+QCSCON=1 //Enable RRC state reported via URC. //Send “123” without RAI information. AT+QISENDEX=0,"313233",0 SEND OK //18:48:14:649 +QCSCON: 1,1 //RRC connection setup successfully. //18:48:35:790 +QCSCON: 1,0 //After 20 s, RRC connection released.
  • Page 52: Ping

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 3.11. PING 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 53: Getting The Last Error Code

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note 3.13. Getting the Last Error Code AT+QIOPEN=1,"TCP","220.180.239.212",8009,0,1 //Start a socket service but and <connectID> is not present. ERROR AT+QIGETERROR +QIGETERROR: 552, invalid parameters BG95&BG77&BG600L_Series_TCP/IP_Application_Note 52 / 56...
  • Page 54: Summary Of Result Codes

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Summary of Result Codes If <result> is returned after executing TCP/IP AT commands, the details of error can be queried with AT+QIGETERROR. Please note that AT+QIGETERROR just returns error code of the last TCP/IP AT command.
  • Page 55 LPWA Module Series BG95&BG77&BG600L Series 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 BG95&BG77&BG600L_Series_TCP/IP_Application_Note 54 / 56...
  • Page 56: Appendix A References

    LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Appendix A References Table 4: Related Document Document Name Description Quectel_BG95&BG77&BG600L_Series_AT_ The AT command manual of BG95 series, BG77 Commands_Manual and BG600L-M3 modules Table 5: Terms and Abbreviations Abbreviation Description 3GPP 3rd Generation Partnership Project...
  • Page 57 LPWA Module Series BG95&BG77&BG600L Series TCP/IP Application Note Quality of Service SACK Selective Acknowledgment Transmission Control Protocol UART Universal Asynchronous Receiver & Transmitter User Datagram Protocol Unsolicited Result Code Universal Serial Bus Coordinated Universal Time BG95&BG77&BG600L_Series_TCP/IP_Application_Note 56 / 56...

This manual is also suitable for:

Bg77 seriesBg600l series

Table of Contents