mirror of
https://gitee.com/god-jason/iot-master.git
synced 2025-12-06 15:09:02 +08:00
添加MQTT规范
This commit is contained in:
1
.gitignore
vendored
1
.gitignore
vendored
@@ -30,3 +30,4 @@ go.work.sum
|
||||
/plugins
|
||||
/iot-master
|
||||
/iot-master.yaml
|
||||
/vendor
|
||||
|
||||
118
README.md
118
README.md
@@ -3,6 +3,7 @@
|
||||
[](https://github.com/god-jason/iot-master/actions/workflows/go.yml)
|
||||
|
||||
物联大师是开源免费的物联网数据中台,区别于传统的物联网平台,物联大师采用Go语言进行编程实现,有以下诸多优点:
|
||||
|
||||
- 单一程序文件,免安装
|
||||
- 最低内存只需要12MB
|
||||
- 插件机制,支持功能自由扩展
|
||||
@@ -14,21 +15,98 @@
|
||||
|
||||
物联大师,物联小白 是本易物联网的一部分,更多信息请关注:[链接](https://busycloud.cn)
|
||||
|
||||
# MQTT主题规范
|
||||
|
||||
物联大师的插件主要通过MQTT总线相互通讯,
|
||||
|
||||
## 一、连接消息
|
||||
|
||||
| 消息 | 主题 | 内容 | 说明 |
|
||||
|------|--------------------------------------|------|---------------------------|
|
||||
| 打开连接 | link/${linker_name}/${link_id}/open | json | {...options, remote:"ip"} |
|
||||
| 关闭连接 | link/${linker_name}/${link_id}/close | none | |
|
||||
| 接收数据 | link/${linker_name}/${link_id}/up | bin | 原始二进制 |
|
||||
| 发送数据 | link/${linker_name}/${link_id}/down | bin | 原始二进制 |
|
||||
|
||||
### 备注:
|
||||
|
||||
1. linker_name:连接器名称,比如:serial、can、tcp、tcp-server、udp、udp-server、udp-group、gnet……
|
||||
2. link_id:连接ID
|
||||
|
||||
## 二、协议插件消息
|
||||
|
||||
| 消息 | 主题 | 内容 | 说明 |
|
||||
|------|----------------------------------------------------|------|------------------------|
|
||||
| 接收数据 | ${protocol_name}/${linker_name}/${link_id}/up | bin | 将原始数据定向发送到协议插件 |
|
||||
| 添加设备 | ${protocol_name}/${linker_name}/${link_id}/attach | json | {product_id,device_id} |
|
||||
| 删除设备 | ${protocol_name}/${linker_name}/${link_id}/detach | json | {device_id} |
|
||||
| 数据轮询 | ${protocol_name}/${linker_name}/${link_id}/polling | none | 由连接器主动发起 |
|
||||
|
||||
### 备注:
|
||||
|
||||
1. protocol_name:协议名称,推荐与插件名称一致,比如:modbus、dlt645、iec104……
|
||||
2. linker_name:连接器名称,目的是方便做数据下发,不用二次转换
|
||||
3. 修改设备,实际操作是先删除,再添加
|
||||
4. 发送数据使用 link/${linker_name}/${link_id}/down
|
||||
5. 插件需要订阅产品消息,同步产品配置
|
||||
|
||||
|
||||
## 三、产品消息
|
||||
|
||||
| 消息 | 主题 | 内容 | 说明 |
|
||||
|------|---------------------------------------------|------|----|
|
||||
| 产品配置 | product/${product_id}/config/${config_name} | json | |
|
||||
| 产品模型 | product/${product_id}/model | json | |
|
||||
|
||||
### 备注:
|
||||
|
||||
1. config_name:配置名称,一般是协议名称,比如:modbus、dlt645、iec104……
|
||||
|
||||
## 四、设备消息
|
||||
|
||||
| 消息 | 主题 | 内容 | 说明 |
|
||||
|--------|---------------------------------------------------|---------------------|--------------------------------------|
|
||||
| 上传属性 | device/${product_id}/${device_id}/values | json: map<k,v> | |
|
||||
| 读取属性 | device/${product_id}/${device_id}/read | json: array[k,] | [var1, var2] |
|
||||
| 读取属性响应 | device/${product_id}/${device_id}/read/response | json: map<k,v> | {var1:1, var2:2} |
|
||||
| 修改属性 | device/${product_id}/${device_id}/write | json: map<k,v> | {var1:1, var2:2} |
|
||||
| 修改属性响应 | device/${product_id}/${device_id}/write/response | json: map<k,string> | {var1:"success", var2:"fail"} |
|
||||
| 上报事件 | device/${product_id}/${device_id}/event | json | {title, message, level,} |
|
||||
| 执行操作 | device/${product_id}/${device_id}/action | json | {action:"reboot", parameters:{}} |
|
||||
| 执行操作响应 | device/${product_id}/${device_id}/action/response | json | {action:"reboot", result: "success"} |
|
||||
|
||||
### 备注:
|
||||
|
||||
## 五、项目消息
|
||||
|
||||
## 六、空间消息
|
||||
|
||||
## 七、异常消息
|
||||
|
||||
# 协议库支持统计
|
||||
|
||||
## 南向协议库
|
||||
- [x] Modbus RTU
|
||||
- [x] Modbus TCP
|
||||
- [ ] Modbus ASCII(使用比较少,暂不做支持)
|
||||
- [ ] PLC
|
||||
- - [x] Siemens 西门子 s7 fetchwrite mpi ppi
|
||||
- - [x] Mitsubishi 三菱 melsec
|
||||
- - [x] Omron 欧姆龙 fins hostlink
|
||||
- - [ ] AB df1
|
||||
- - [ ] Delta 台达 dvp
|
||||
- - [ ] Keyence 基恩士 melsec
|
||||
- - [ ] Panasonic 松下 melsec newtocol
|
||||
- - [ ] Fuji 富士 spb
|
||||
- - [ ] Fatek 永宏
|
||||
-
|
||||
- [x] Siemens 西门子 s7 fetchwrite mpi ppi
|
||||
-
|
||||
- [x] Mitsubishi 三菱 melsec
|
||||
-
|
||||
- [x] Omron 欧姆龙 fins hostlink
|
||||
-
|
||||
- [ ] AB df1
|
||||
-
|
||||
- [ ] Delta 台达 dvp
|
||||
-
|
||||
- [ ] Keyence 基恩士 melsec
|
||||
-
|
||||
- [ ] Panasonic 松下 melsec newtocol
|
||||
-
|
||||
- [ ] Fuji 富士 spb
|
||||
-
|
||||
- [ ] Fatek 永宏
|
||||
- [ ] BACnet智能建筑协议
|
||||
- [ ] KNX智能建筑协议
|
||||
- [x] DL/T645-1997、2007 多功能电表通讯规约
|
||||
@@ -41,30 +119,14 @@
|
||||
- [ ] SL/T812.1-2021 水利监测数据传输规约
|
||||
- [ ] SZY206-2016 水资源监测数据传输规约
|
||||
|
||||
|
||||
## 北向云平台
|
||||
- [x] 本易物联设备托管云
|
||||
- [x] HTTP
|
||||
- [x] MQTT
|
||||
- [ ] 主流云平台
|
||||
- - [ ] 阿里云
|
||||
- - [ ] 腾讯云
|
||||
- - [ ] 华为云
|
||||
- - [ ] 百度云
|
||||
- - [ ] 京东云
|
||||
- - [ ] 涂鸦云
|
||||
- - [ ] OneNET
|
||||
|
||||
|
||||
|
||||
## 联系方式
|
||||
# 联系方式
|
||||
|
||||
南京本易物联网有限公司
|
||||
|
||||
- 邮箱:[jason@zgwit.com](mailto:jason@zgwit.com)
|
||||
- 手机:[15161515197](tel:15161515197)(微信同号)
|
||||
|
||||
## 开源协议
|
||||
# 开源协议
|
||||
|
||||
[GNU GPLv3](https://github.com/god-jason/iot-master/blob/main/LICENSE)
|
||||
|
||||
|
||||
@@ -7,13 +7,18 @@ import (
|
||||
|
||||
func init() {
|
||||
api.Register("GET", "iot/device/:id/values", deviceValues)
|
||||
api.Register("GET", "iot/device/:id/values/refresh", deviceValuesRefresh)
|
||||
}
|
||||
|
||||
func deviceValues(ctx *gin.Context) {
|
||||
d := devices.Load(ctx.Param("id"))
|
||||
if d == nil {
|
||||
api.Fail(ctx, "device not found")
|
||||
api.Fail(ctx, "设备未上线")
|
||||
return
|
||||
}
|
||||
api.OK(ctx, d.Values)
|
||||
}
|
||||
|
||||
func deviceValuesRefresh(ctx *gin.Context) {
|
||||
api.OK(ctx, "暂未支持")
|
||||
}
|
||||
|
||||
@@ -2,13 +2,23 @@
|
||||
"title": "实时状态",
|
||||
"template": "statistic",
|
||||
"toolbar": [
|
||||
{
|
||||
"type": "button",
|
||||
"label": "更新数据",
|
||||
"action": {
|
||||
"type": "script",
|
||||
"script": "this.refresh_values()"
|
||||
}
|
||||
}
|
||||
],
|
||||
"items": [],
|
||||
"auto_refresh": 10,
|
||||
"load_api": "iot/device/:id/values",
|
||||
"mount": "this.load_device(); this.value_action={type:'dialog',page:'iot/device-history',params_func:'return {id:this.params.id, point:data.key}'}",
|
||||
"methods": {
|
||||
"load_values": "this.request.get('iot/device/'+this.params.id+'/values').subscribe(res=>{if(res.error)return; this.data=res.data})",
|
||||
"load_values": "this.request.get('iot/device/'+this.params.id+'/values').subscribe(res=>{if(res.error)return; this.data=res.data; this.content.toolbar[0].type='text'; label=res.data.__update})",
|
||||
"refresh_values": "this.request.get('iot/device/'+this.params.id+'/values/refresh').subscribe(res=>{if(res.error)return; this.data=res.data})",
|
||||
"load_device": "this.request.get('iot/device/'+this.params.id).subscribe(res=>{if(res.error)return; this.load_model(res.data.product_id)})",
|
||||
"load_model": ["pid","this.request.get('iot/product/'+pid+'/model').subscribe(res=>{if(res.error)return; this.content.items=res.data.properties.map(p=>{return{key:p.name,label:p.label,suffix:p.unit,span:6,action:this.value_action}}) })"]
|
||||
"load_model": ["pid","this.request.get('iot/product/'+pid+'/model').subscribe(res=>{if(res.error)return; this.content.items=res.data.properties.map(p=>{return{key:p.name,label:p.label,suffix:p.unit,span:6,action:this.value_action}}); })"]
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user