NB-IoT学习笔记:三、连接UDP服务器并传输数据

文章目录

  • 1.创建Socket,连接服务器
  • 2.发送数据,仅限 UDP
  • 3.接收服务器数据
  • 4.关闭Socket,断开连接

1.创建Socket,连接服务器

/* Use AT+NSOCR to create a socket on the UE and associates with specified protocol */
[2020-06-15 09:50:55:019_S:] AT+NSOCR=DGRAM,17,1001,1
[2020-06-15 09:50:55:147_R:] AT+NSOCR=DGRAM,17,1001,1
[2020-06-15 09:50:55:147_R:] 1

[2020-06-15 09:50:55:147_R:] OK

2.发送数据,仅限 UDP

[2020-06-15 09:55:13:825_S:] AT+NSOST=1,47.105.44.99,1001,4,54455354
[2020-06-15 09:55:14:001_R:] AT+NSOST=1,47.105.44.99,1001,4,54455354
[2020-06-15 09:55:14:023_R:] 1,4

[2020-06-15 09:55:14:023_R:] OK

服务器接收到数据
NB-IoT学习笔记:三、连接UDP服务器并传输数据_第1张图片

3.接收服务器数据

[2020-06-15 09:58:26:871_R:] +NSONMI:1,9
[2020-06-15 09:58:26:871_S:] AT+NSORF=1,9
[2020-06-15 09:58:27:004_R:] AT+NSORF=1,9
[2020-06-15 09:58:27:004_R:] 1,47.105.44.99,1001,9,544553545F52454356,0

[2020-06-15 09:58:27:037_R:] OK

4.关闭Socket,断开连接

/* Use AT+NSOCL to close the connection of UDP */
[2020-06-15 09:53:00:493_S:] AT+NSOCL=1
[2020-06-15 09:53:00:557_R:] AT+NSOCL=1
[2020-06-15 09:53:00:557_R:] OK

你可能感兴趣的:(NB-iot笔记)