实际给客户用了下这个设备,发现蛮好用,价格也便宜,非常推荐!!(SIM卡还8年免流,省去了客户自己注册流量卡的麻烦)备份下文档和型号
一、功能介绍:(同官网说明书)
数据读写功能主要是服务器通过链路通道下发查询和设置命令,通过该命令直接获取点位数据或者修改点位数据的操作。和主动上报 功能可以同时运行。数据的读和写功能需要开启使能,设定好点位读写的协议方式,云端按照设定好的通信协议进行点位数据的获取和修改控制。
注:边缘网关的数据读写功能,只能读和写已经配置好的点表数据,非点表数据无法操作。
通道选择:如果选择MQTT,阿里云,AWS等MQTT通信方式的通道,需要单独配置读写的订阅和发布主题。
读写方式:支持ModbusRTU,ModbusTCP和Json,其中Json具有固定的协议。
Json 读写命令格式:(可以同时获取多个点位数据)
{"rw_prot":{"Ver":"协议版本","dir":"数据走向","id":"信息编号","r_data":[{"name":"点位名称"}],"w_data":[{"name":"点位名称 ","value":"data"}]}}
Json读写命令字段说明:
字段名称 | 字段说明 | 字段选择 |
rw_prot | 协议包头 | |
ver | 协议版本 | 1.0.1 |
dir | 数据走向,服务器下发命令填入down | down:服务器下发 |
id | 服务器下发数据的编码,可以作为序列识别使用 | 客户自定义,设备回复不做改变 |
r_data | 数据读取字段 | |
w_data | 数据控制字段 | |
name | 点位名称,和点表中的点位名称一致即可代入点位 | |
value | 读写命令中仅有写有value字段,为写入的有效值 |
Json读写回复格式:
{"rw_prot": {"Ver": "协议版本","dir": "数据走向","id": "信息编号","r_data": [{"name": "点位名称","value": "data","err": "错误码"}],"w_data": [{"name": "点位名称","value": "data","err": "错误码"}]}}
Json读写回复字段说明:
字段名称 | 字段说明 | 字段选择 |
---|---|---|
rw_prot | 协议包头 | |
ver | 协议版本 | 1.0.1 |
dir | 数据走向,设备回复内容填入up | up:设备回复 |
id | 信息识别码,保持和下发命令一致 | |
r_data | 数据读取字段 | |
w_data | 数据控制字段 | |
name | 点位名称,对应点表中的点位 | |
value | 点位对应的有效数据 | 读错误,value有效值为空写错误,value值为历史值 |
err | 错误码 | 0:数据正常执行1:数据错误执行 |
Json字段错误回复:
Json格式错误:设备不做回复
ver,dir,id三个字段,任意一个错误,则按照错误协议进行回复。
其他字段正确,r_data或w_data字段仅错误一个,则错误的字段舍弃,正确字段进行回复;如果两个字段都错误,按照错误协议回复。
错误协议:"rw_prot": {"Ver": "1.0.1","dir": "up","err":"1"}
字段名称 | 字段说明 | 字段选择 |
---|---|---|
rw_prot | 协议包头 | |
ver | 协议版本 | 1.0.1 |
dir | 数据走向,上报和下发两种 | up:设备回复 |
err | 错误码 | 0:正常执行1:错误执行 |
说明:
读写命令错误时,读命令回复内容的value值为空,写命令的回复内容的value值为历史数据值。
读写操作最大上限为读写各5个数据点位同时操作。
二、示例
点表示例
1、 读1个点位值: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0201" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0201","value":"1","err":"0"}]}} 2、读2个点位值: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0201" }, { "name": "node0202" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0201","value":"1","err":"0"},{"name":"node0202","value":"2","err":"0"}]}} 3、读3个点位值: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0201" }, { "name": "node0202" }, { "name": "node0203" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0201","value":"1","err":"0"},{"name":"node0202","value":"2","err":"0"},{"name":"node0203","value":"3","err":"0"}]}} 4、读4个点位值: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0201" }, { "name": "node0202" }, { "name": "node0203" }, { "name": "node0204" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0201","value":"1","err":"0"},{"name":"node0202","value":"2","err":"0"},{"name":"node0203","value":"3","err":"0"},{"name":"node0204","value":"4","err":"0"}]}} 5、读5个点位值: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0201" }, { "name": "node0202" }, { "name": "node0203" }, { "name": "node0204" }, { "name": "node0205" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0201","value":"1","err":"0"},{"name":"node0202","value":"2","err":"0"},{"name":"node0203","value":"3","err":"0"},{"name":"node0204","value":"4","err":"0"},{"name":"node0205","value":"5","err":"0"}]}} 6、写1个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "w_data": [{ "name": "node0201", "value": "100" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","w_data":[{"name":"node0201","value":"100","err":"0"}]}} 7、写2个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "w_data": [{ "name": "node0201", "value": "100" }, { "name": "node0202", "value": "200" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","w_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"}]}} 8、写3个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "w_data": [{ "name": "node0201", "value": "100" }, { "name": "node0202", "value": "200" }, { "name": "node0203", "value": "300" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","w_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"},{"name":"node0203","value":"300","err":"0"}]}} 9、写4个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "w_data": [{ "name": "node0201", "value": "100" }, { "name": "node0202", "value": "200" }, { "name": "node0203", "value": "300" }, { "name": "node0204", "value": "400" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","w_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"},{"name":"node0203","value":"300","err":"0"},{"name":"node0204","value":"400","err":"0"}]}} 10、写5个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "w_data": [{ "name": "node0201", "value": "100" }, { "name": "node0202", "value": "200" }, { "name": "node0203", "value": "300" }, { "name": "node0204", "value": "400" }, { "name": "node0205", "value": "500" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","w_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"},{"name":"node0203","value":"300","err":"0"},{"name":"node0204","value":"400","err":"0"},{"name":"node0205","value":"500","err":"0"}]}} 11、读1个点位写1个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0202" }], "w_data": [{ "name": "node0201", "value": "100" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0202","value":"200","err":"0"}],"w_data":[{"name":"node0201","value":"100","err":"0"}]}} 12、读2个点位写2个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0201" }, { "name": "node0202" }], "w_data": [{ "name": "node0201", "value": "100" }, { "name": "node0202", "value": "200" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"}],"w_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"}]}} 13、读3个点位写3个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0201" }, { "name": "node0202" }, { "name": "node0203" }], "w_data": [{ "name": "node0201", "value": "100" }, { "name": "node0202", "value": "200" }, { "name": "node0203", "value": "300" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"},{"name":"node0203","value":"300","err":"0"}],"w_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"},{"name":"node0203","value":"300","err":"0"}]}} 14、读4个点位写4个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0201" }, { "name": "node0202" }, { "name": "node0203" }, { "name": "node0204" }], "w_data": [{ "name": "node0201", "value": "100" }, { "name": "node0202", "value": "200" }, { "name": "node0203", "value": "300" }, { "name": "node0204", "value": "400" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"},{"name":"node0203","value":"300","err":"0"},{"name":"node0204","value":"400","err":"0"}],"w_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"},{"name":"node0203","value":"300","err":"0"},{"name":"node0204","value":"400","err":"0"}]}} 15、读5个点位写5个点位: 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "r_data": [{ "name": "node0201" }, { "name": "node0202" }, { "name": "node0203" }, { "name": "node0204" }, { "name": "node0205" }], "w_data": [{ "name": "node0201", "value": "100" }, { "name": "node0202", "value": "200" }, { "name": "node0203", "value": "300" }, { "name": "node0204", "value": "400" }, { "name": "node0205", "value": "500" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","r_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"},{"name":"node0203","value":"300","err":"0"},{"name":"node0204","value":"400","err":"0"},{"name":"node0205","value":"500","err":"0"}],"w_data":[{"name":"node0201","value":"100","err":"0"},{"name":"node0202","value":"200","err":"0"},{"name":"node0203","value":"300","err":"0"},{"name":"node0204","value":"400","err":"0"},{"name":"node0205","value":"500","err":"0"}]}} 16、 DO1闭合,DO2断开 下发: { "rw_prot": { "Ver": "1.0.1", "dir": "down", "id": "123", "w_data": [{ "name": "DO1", "value": "1" }, { "name": "DO2", "value": "0" }] } } 响应: {"rw_prot":{"Ver":"1.0.1","dir":"up","id":"123","w_data":[{"name":"DO1","value":"1","err":"0"},{"name":"DO2","value":"0","err":"0"}]}}
编写人:马玲玉 编写日期:2024-06-14
审核人:尹丛欣 审核日期:2024-07-04
订正版本:V1.0 订正内容:初稿
原文来源:https://www.usr.cn/Faq/2312.html
文章评论