TCP/UDP Exercise
Using LTE CAT-M1 Module, Let’s practice TCP/UDP network communication.
Example TCP Echo Server:
TCP Echo server | Description | IP | Port |
echo.mbedcloudtesting.com | 52.215.34.155 | 7 | |
tcpbin.com (“https://tcpbin.com/” to get certificate) |
45.79.112.203 | 4242 | |
Echo with TLS encryption | 45.79.112.203 | 4243 | |
Echo with mutual authentication | 45.79.112.203 | 4244 |
TCP/UDP Command Flow
1. TCP/UDP → SIM7070, SIM7080, SIM7090
NO | Command | Response | Description |
1 | PDP Context 설정 | See & Refer to corresponding page | |
2 | AT+CNACT? | +CNACT: 0,1,”10.61.95.221″ +CNACT: 1,0,”0.0.0.0″ +CNACT: 2,0,”0.0.0.0″ +CNACT: 3,0,”0.0.0.0″ |
Check PDP is activated |
– | AT+CNACT=0,1 |
+CGATT: 1 OK |
Activate network, Activate 0th PDP. |
– | AT+CASWITCH=0,1 | OK | Transparent Mode |
3 | AT+CASSLCFG=0,”SSL”,0 | OK | Set the 0th connection’s SSL option. |
4 |
AT+CAOPEN=0,0,”TCP”,”echo.mbedcloud testing.com”,7 |
+CAOPEN: 0,0 OK |
Create a TCP connection with 0th PDP on the 0th connection. |
5 | AT+CASEND=0,5 | > | Input 5 byte in time after response of “>” |
6 | Hello |
OK +CADATAIND: 0 |
Input 5 Byte |
– | +++ | Exit from Transparent Mode | |
7 | AT+CAACK=0 |
+CAACK: 5,0 OK |
Query send data Information of the TCP connection with an identifier 0. |
8 | AT+CARECV=0,100 |
+CARECV: 5,Hello OK |
Request to get 100 byte data sent by the server (No need if RX push mode) |
9 | AT+CACLOSE=0 | OK | Close the connection with an identifier of 0. |
10 | AT+CNACT=0,0 |
OK +APP PDP: 0,DEACTIVE |
Disconnect 0th data connection |
2. TCP/UDP → SIM7000
NO | Command | Response | Description |
1 | PDP Context 설정 | See & Refer to corresponding page | |
– | AT+CIPMUX? | ||
– | AT+CIPMODE? | ||
— | AT+CIPMODE? | ||
AT+CGATT=1 | |||
1 | AT+CGATT? | ||
AT+CSTT=”connect.cxn” | |||
AT+CIICR | |||
AT+CIFSR | |||
2 | AT+CIPSTART=”TCP”,”45.79.112.203″,4242 | ||
3 | AT+CIPSEND=6\r | > | |
4 | Hello | ||
5 | AT+CIPCLOSE | ||