We shall create a UDP “connection” to our UDP Test Server with a BG96. The server simply replies whatever is typed into the prompt/terminal.
1.0 Remote Host Details
The following table lists the remote server details.
2.0 Start a UDP Service 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. Start a UDP Service
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,2,"UDP SERVICE","127.0.0.1",0,3030,0 OK +QIOPEN: 2,0
Query if the connection status of the associated context id, in our case its 1.
AT+QISTATE=0,1 +QISTATE: 2,"UDP SERVICE","10.121.9.118",0,3030,2,1,2,0,"usbmodem" OK
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",2
2.3. Read the Data
Read the echoed text with the following command.
AT+QIRD=2 +QIRD: 6,"126.96.36.199",3000 hello OK
2.4. Close the UDP Service
To be polite we shall close the active UDP service with the following command:
3.0 AT Command Sequence
Bellow is the complete command sequence.
AT+QICSGP=1,1,"telstra.internet","","",1 OK AT+QIACT=1 OK AT+QIACT? +QIACT: 1,1,1,"10.102.135.75" OK AT+QIOPEN=1,2,"UDP SERVICE","127.0.0.1",0,3030,0 OK +QIOPEN: 2,0 AT+QISEND=2,6,"188.8.131.52",3000 >hello SEND OK +QIURC: "recv",2 AT+QIRD=2 +QIRD: 6,"184.108.40.206",3000 hello OK