fix event
This commit is contained in:
parent
0d30cd471e
commit
2465fa5bab
@ -412,6 +412,19 @@ handle_cast({handle, {event, Event0}}, State = #state{uuid = UUID, aes = AES, ha
|
|||||||
lager:debug("[iot_host] uuid: ~p, get event: ~p", [UUID, EventText]),
|
lager:debug("[iot_host] uuid: ~p, get event: ~p", [UUID, EventText]),
|
||||||
case catch jiffy:decode(EventText, [return_maps]) of
|
case catch jiffy:decode(EventText, [return_maps]) of
|
||||||
#{<<"event_type">> := ?EVENT_DEVICE, <<"params">> := #{<<"device_uuid">> := DeviceUUID, <<"status">> := Status}} ->
|
#{<<"event_type">> := ?EVENT_DEVICE, <<"params">> := #{<<"device_uuid">> := DeviceUUID, <<"status">> := Status}} ->
|
||||||
|
%% 设备的状态信息上报给中电
|
||||||
|
Timestamp = iot_util:timestamp_of_seconds(),
|
||||||
|
FieldsList = [#{
|
||||||
|
<<"key">> => <<"device_status">>,
|
||||||
|
<<"value">> => Status,
|
||||||
|
<<"unit">> => <<"">>,
|
||||||
|
<<"type">> => <<"SOE">>,
|
||||||
|
<<"name">> => <<"设备状态"/utf8>>,
|
||||||
|
<<"timestamp">> => Timestamp
|
||||||
|
}],
|
||||||
|
iot_router:route(DeviceUUID, FieldsList, Timestamp),
|
||||||
|
lager:debug("[iot_host] uuid: ~p, route fields: ~p", [UUID, FieldsList]),
|
||||||
|
|
||||||
DevicePid = iot_device:get_pid(DeviceUUID),
|
DevicePid = iot_device:get_pid(DeviceUUID),
|
||||||
iot_device:change_status(DevicePid, Status);
|
iot_device:change_status(DevicePid, Status);
|
||||||
Event when is_map(Event) ->
|
Event when is_map(Event) ->
|
||||||
|
|||||||
58
docs/zhongdian_mqtt.md
Normal file
58
docs/zhongdian_mqtt.md
Normal file
@ -0,0 +1,58 @@
|
|||||||
|
# 中电mqtt通讯规约
|
||||||
|
## 服务器地址
|
||||||
|
MQTT服务器IP:172.30.6.161
|
||||||
|
MQTT服务器端口:1883
|
||||||
|
MQTT服务器账号:admin
|
||||||
|
MQTT服务器密码:public
|
||||||
|
|
||||||
|
## topic
|
||||||
|
南向:
|
||||||
|
MQTT ClientID: CET/NX
|
||||||
|
发布Topic:CET/NX/upload
|
||||||
|
订阅Topic:CET/NX/downlod
|
||||||
|
|
||||||
|
中电:
|
||||||
|
MQTT ClientID:CET/NX
|
||||||
|
订阅Topic:CET/NX/upload
|
||||||
|
发布Topic:CET/NX/download
|
||||||
|
|
||||||
|
## 数据格式
|
||||||
|
```text
|
||||||
|
{
|
||||||
|
"version": "1.0",
|
||||||
|
"location_code": "string",
|
||||||
|
"ts ": 1688606685,
|
||||||
|
"properties": [
|
||||||
|
{
|
||||||
|
"type": "AI",
|
||||||
|
"key": "A相电流",
|
||||||
|
"value": 0.25,
|
||||||
|
"unit": "A",
|
||||||
|
"timestamp": 1688354258
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "AI",
|
||||||
|
"key": "A相电压",
|
||||||
|
"value": 220.5,
|
||||||
|
"unit": "V",
|
||||||
|
"timestamp": 1688354258
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"type": "SOE",
|
||||||
|
"key": "电压越限",
|
||||||
|
"value": 1,
|
||||||
|
"unit": "V",
|
||||||
|
"timestamp": 1688354258
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
||||||
|
|
||||||
|
南向上送数据
|
||||||
|
|
||||||
|
CET应答:
|
||||||
|
{
|
||||||
|
"location_code": string, //(点位编码信息),
|
||||||
|
"ts ":1688606685 ,
|
||||||
|
"result":1(int)
|
||||||
|
}
|
||||||
|
```
|
||||||
Loading…
x
Reference in New Issue
Block a user