In this tutorial, we will learn how to create a UDP connection with Cellular IoT HAT and Cellular IoT App Shield.
Remote Host Details
The following table lists the remote server details.
Start a UDP Service and Send Data
Initially, it's required to configure and activate a context. In our example, we are using a Sixfab Connect SIM and the APN may be different in your case.
Configure a Context and Activate
If you are using Super SIM from Sixfab, the following parameters are used:
Send the following AT Commands using minicom by following the tutorial here.
Configure and Activate Context:
Activate the context:
Check the active context:
“100.66.113.251” is the IP address associated to our active context. address will be different in your case.
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 Manual document for a detailed explanation of the data access modes.
Start a UDP service, is 2 and is 1. Before using AT+QIOPEN, the host should activate the context with AT+QIACT first.
Query if the connection status of the associated context id, in our case it's 1.
Send Data to the Remote
We will now send the text
“hello" 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.
Receive Data From Remote
Read the echoed text with the following command. One whole UDP packet will be outputted. There is no need to specify the read length.
Close the UDP Service
To be polite we shall close the active UDP service with the following command:
Ping www.baidu.com in context 1. Before pinging the destination IP address, the host should activate
the context by AT+QIACT first.