This guide will guide you through the steps on how to open a TCP/IP connection to a remote server with AT commands. The aim is to establish a non secure connection to our TCP Test Server with a BG96. The TCP Test Server simply replies whatever is typed into the prompt/console sent by the BG96.
1.0 Establish a Remote Connection with Putty or NC
Firstly lets verify that we are able to connect from our PC to the TCP Test Server. This is to verify that the TCP Test Server is running and that the IP and Port to the remote host is correct.
Open the console and type the following:
nc 126.96.36.199 3000
Once connected, the server will prompt:
nc 188.8.131.52 3000 Quectel TCP Echo Server >
Use putty to establish a raw connection with the following details:
Host Name (or IP address):
Select the connection type:
Click Open and if successful you shall be prompted with a welcome text followed by a ‘>’. Type some text and hit Enter. The text typed shall be echoed back.
We are now ready to continue on to the next step and use a BG96 to connect to the TCP Test Server.
2.0 Open a Remote Connection and Send Data
Initially its required to configure and activate a context. In our example we are using a Telstra SIM and the APN may be different in your case.
Before continuing on please make sure you disable the Power Save Mode: AT+CPSMS=0
2.1. Configure a Context and Activate
For Telstra SIM the following parameters are used:
Send the following AT Commands using your preferred terminal program such as QCOM or Putty. On how to connect to the BG96 with USB/Serial please refer to the /wiki/how-to/establish-a-virtual-com-port-connection-to-bg96-with-usb/
Configure and Activate Context:
Activate the context:
Check the active context:
AT+QIACT? +QIACT: 1,1,1,"10.102.135.75" OK
“10.102.135.75” is the IP address associated to our active context. The IP returned for you will be different.
2.2. Open a Socket Service with Direct Push Mode
There are three types of data access modes available when opening a socket service.
- Buffer access mode
- Direct push mode
- Transparent access mode
In our example we shall use direct push mode. Please refer to the Quectel BG96 TCP(IP) AT Commands document for a detailed explanation of the data access modes.
AT+QIOPEN=1,0,"TCP","184.108.40.206",3000,0,1 OK +QIOPEN: 0,0 +QIURC: "recv",0,27 Quectel TCP Echo Server >
Note that the ‘Quectel TCP Echo Server\r\n> ‘ is received text from the remote TCP Test Server.
2.3. Send Data to the Remote Server
We will now send the text “hello\r” to the remote server. For this we shall use the fixed length AT+QISEND command.
After the “>” is prompted we are ready to send the text.
> hello SEND OK +QIURC: "recv",0,6 hello
At this point we have received the echoed response from the server.
QCOM enter the text and press Send Command
2.4. Close the Connection
To be polite we shall close the active TCP socket service with the following command:
3.0 AT Command Sequence
Bellow is the complete command sequence from QCOM used in the example.
AT+QICSGP=1,1,"telstra.internet","","",1 OK AT+QIACT=1 OK AT+QIACT? +QIACT: 1,1,1,"10.102.187.225" OK AT+QIOPEN=1,0,"TCP","220.127.116.11",3000,0,1 OK +QIOPEN: 0,0 +QIURC: "recv",0,27 Quectel TCP Echo Server > AT+QISEND=0,6 > hello SEND OK +QIURC: "recv",0,6 hello AT+QICLOSE=0 OK