This post was last edited by Li Baiyi on 2021-12-22 21:12
In the previous chapter, we mentioned that the communication between PC and EC-01F has been established. Now we start to create Socket communication.
1 Test baud rate
AT\r
2 Turn off echo
ATE0\r
3 Check whether the SIM card is normal
AT+ECICCID\r
4 Attach to the network (before attaching to the network, the following conditions must be met: the network card has traffic, the antenna is an NB-IoT antenna, and the SIM card ID can be queried)
AT+CGATT=1\r
5 Register APNID (successful network attachment proves that you can access the network, and then set APNID to access the Internet)
AT+CGDCONT=1,"IP","CMNET"\r
6 Activate the network (After successful registration, you can directly activate the network and officially connect to the Internet. (Network activation requires successful APNID testing))
AT+CGACT=1\r
7 Create a socket for TCP protocol
AT+SKTCREATE=1,1,6\r (1 is IPV4, 1 is TCP mode, 6 is IPPROTO_TCP TCP protocol definition)
8. Use Peanut Shell to create intranet penetration
9 Initiate connection (fd: fd, addr, port returned when creating the socket)
AT+SKTCONNECT=0,"116.62.200.72",10520\r
10 Sending Data
AT+SKTSEND=0,5,3132333435\r
11 Close Socket
AT+SKTDELETE=0\r
Test project file:
EC_01F_TCP.bsp
(7.35 KB, downloads: 4)
, open the project file on the host computer: Geshi Fenghuo