IG902 内部APP实现数据互访

1.进入设备web管理界面,运行device_supervisor app程序,选择 设备监控->云服务.

/uploads/article/20201211/635aed843da5cc9da5e34168bd94ee6e.png

2.配置 发布功能(需要明白mqtt协议的组概念,同一组中可以接收数据,及A发布主题 为topic_A,B 和 c 同时订阅 topic_A,则B和C能同时收到数据)

/uploads/article/20201211/43fceb34dc377a7695bcb273a9197610.png

定义发布主题为jieshou, Qos 为1.

3.添加采集数据的相关信息

/uploads/article/20201211/5bc0b6cd5e0b853455a3548554cd2aa4.png

4.模拟客户自行开发的APP实现与device_supervisor 通讯.

4.1 开启IG网关 调试模式.

/uploads/article/20201211/d4e69c48f4191d103ed50581464aaaf8.png

4.2 通过ssh 222端口连接 设备用户名密码 如上图

/uploads/article/20201211/a94075df27e0ff06200b3cab7e8c8193.png

3.3 编写测试代码

import paho.mqtt.client as mqtt

def on_connect(client, userdata, flags, rc):
print("Connected with result code: " + str(rc))

def on_message(client, userdata, msg):
print(msg.topic + " " + str(msg.payload))

client = mqtt.Client()
client.on_connect = on_connect
client.on_message = on_message
client.connect('127.0.0.1', 9009, 600)
client.subscribe('jieshou', qos=1)
client.loop_forever()

4.3运行py文件,查看接收数据

/uploads/article/20201211/a68885cb5873c276111778e849c5b810.png

0 个评论

要回复文章请先登录注册