提交 162d1848 authored 作者: zxd's avatar zxd

发送emqq

上级 ebe06f77
...@@ -11,6 +11,13 @@ ...@@ -11,6 +11,13 @@
"random_type": 1, "random_type": 1,
"port": "a", "port": "a",
"port_address": 0 "port_address": 0
},
{
"measurement": "door",
"type": 0,
"random_type": 1,
"port": "c",
"port_address": 1
} }
] ]
}, },
...@@ -26,6 +33,13 @@ ...@@ -26,6 +33,13 @@
"random_type": 1, "random_type": 1,
"port": "a", "port": "a",
"port_address": 0 "port_address": 0
},
{
"measurement": "door",
"type": 0,
"random_type": 1,
"port": "c",
"port_address": 1
} }
] ]
}, },
...@@ -41,6 +55,13 @@ ...@@ -41,6 +55,13 @@
"random_type": 1, "random_type": 1,
"port": "a", "port": "a",
"port_address": 0 "port_address": 0
},
{
"measurement": "door",
"type": 0,
"random_type": 1,
"port": "c",
"port_address": 1
} }
] ]
} }
......
...@@ -73,9 +73,13 @@ def getTelemetry(param): ...@@ -73,9 +73,13 @@ def getTelemetry(param):
l = len(param) l = len(param)
tjsons = [] tjsons = []
for i in range(l): for i in range(l):
v = random.randint(0, 1000)
# 门开关只有0 1
if param[i].get("measurement") == "door":
v = random.randint(0, 1)
dataT = telemetryTemplate.format(port=param[i].get("port"), protAddress=param[i].get("port_address"), dataT = telemetryTemplate.format(port=param[i].get("port"), protAddress=param[i].get("port_address"),
time=str(t), time=str(t),
measurement=param[i].get("measurement"), value=str(random.randint(0, 1000))) measurement=param[i].get("measurement"), value=str(v))
tJson = json.loads(dataT) tJson = json.loads(dataT)
tjsons.append(tJson) tjsons.append(tJson)
return json.dumps(tjsons) return json.dumps(tjsons)
......
Markdown 格式
0%
您添加了 0 到此讨论。请谨慎行事。
请先完成此评论的编辑!
注册 或者 后发表评论