IG902 内部APP实现数据互访

yandongjie
yandongjie This guy is lazy,Introduction has not been set

0 People liked this article · 5061 views

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

635aed843da5cc9da5e34168bd94ee6e.png

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

43fceb34dc377a7695bcb273a9197610.png

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

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

5bc0b6cd5e0b853455a3548554cd2aa4.png

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

4.1 开启IG网关 调试模式.

d4e69c48f4191d103ed50581464aaaf8.png

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

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文件,查看接收数据

a68885cb5873c276111778e849c5b810.png


注意:IG 里面开启 9009 只对设备本机内部APP互访数据有效, 不对外提供服务(外部通过IG地址加端口访问).

Published on 2020-12-11 11:59

Disclaimers:

This document is written by yandongjie Original published on 技术社区 ,The copyright belongs to the author。

Log in,More exciting content waiting for you to find,Contribute wonderful answers,Participate in comment interaction

go Sign in! No accountgoregister