LPWA Module Series
BG95&BG77&BG600L Series TCP/IP Application Note
BG95&BG77&BG600L_Series_TCP/IP_Application_Note 45 / 56
3.6. TCP Server Works in Buffer Access Mode under IPv4 Network
3.6.1. Start a TCP Server
3.6.2. Accept TCP Incoming Connection
3.6.3. Retrieve Data from Incoming Connection
//Context is 1 and
<connectID>
is 1. Before using
AT+QIOPEN
, the host should activate the context
with
AT+QIACT
first.
AT+QIOPEN=1,1,"TCP LISTENER","127.0.0.1",0,2020,0
OK
+QIOPEN: 1,0
//TCP server is opened successfully.
AT+QISTATE=0,1
//Query the connection status of context 1.
+QISTATE: 1,"TCP LISTENER","10.7.157.1",0,2020,3,1,1,0,"usbmodem"
OK
+QIURC: "incoming",11,1,"172.31.242.222",54091
//A new TCP connection is accepted. The
<service_type>
is "TCP incoming", and
<connectID>
is 11.
+QIURC: "recv",11
//Received data from remote incoming connection.
AT+QIRD=11,1500
//Retrieve the data received from incoming connection.
+QIRD: 4
//Actually retrieved data length is 4 bytes.
test
OK
AT+QIRD=11,1500
+QIRD: 0
//No data in buffer.
OK
AT+QIRD=11,0
//Query the total length of received data, including read and unread data.
+QIRD: 4,4,0
OK