mirror of
https://gitee.com/dgiiot/dgiot.git
synced 2024-11-30 03:07:40 +08:00
feat: topic add /user;modbus env = <<>>
This commit is contained in:
parent
3623170264
commit
1da746f771
@ -141,5 +141,5 @@ do_task(_Task, _State) ->
|
||||
ok.
|
||||
|
||||
send(DashboardId, Base64) ->
|
||||
Topic = <<"$dg/dashboard/", DashboardId/binary, "/report">>,
|
||||
Topic = <<"$dg/user/dashboard/", DashboardId/binary, "/report">>,
|
||||
dgiot_mqtt:publish(self(), Topic, Base64).
|
||||
|
@ -113,7 +113,7 @@ handle_message({rule, #{clientid := _DevAddr, connected_at := _ConnectedAt} = _M
|
||||
handle_message({rule, #{clientid := _DevAddr, disconnected_at := _DisconnectedAt} = _Msg, _Context}, State) ->
|
||||
{ok, State};
|
||||
|
||||
%% SELECT payload.electricity as electricity FROM "$dg/alarm/94656917ab/157d0ff60f/#" where electricity > 20
|
||||
%% SELECT payload.electricity as electricity FROM "$dg/user/alarm/94656917ab/157d0ff60f/#" where electricity > 20
|
||||
handle_message({rule, #{metadata := #{rule_id := <<"rule:Notification_", Ruleid/binary>>}, clientid := DeviceId, payload := _Payload, topic := _Topic} = _Msg, Context}, State) ->
|
||||
dgiot_umeng:add_notification(Ruleid, DeviceId, Context),
|
||||
{ok, State};
|
||||
|
@ -76,7 +76,7 @@ handle_info({tcp, Buff}, #tcp{socket = Socket, state = #state{id = ChannelId, de
|
||||
end
|
||||
end;
|
||||
|
||||
handle_info({tcp, Buff}, #tcp{state = #state{id = ChannelId, devaddr = DtuAddr, env = #{product := ProductId, pn := Pn, di := Di}, product = DtuProductId}} = TCPState) ->
|
||||
handle_info({tcp, Buff}, #tcp{state = #state{id = ChannelId, devaddr = DtuAddr, env = #{product := ProductId, pn := Pn, di := Di}, product = DtuProductId} = State} = TCPState) ->
|
||||
dgiot_bridge:send_log(ChannelId, ProductId, DtuAddr, "~s ~p DTU ~p recv ~p", [?FILE, ?LINE, DtuAddr, dgiot_utils:binary_to_hex(Buff)]),
|
||||
<<H:8, L:8>> = dgiot_utils:hex_to_binary(modbus_rtu:is16(Di)),
|
||||
<<Sh:8, Sl:8>> = dgiot_utils:hex_to_binary(modbus_rtu:is16(Pn)),
|
||||
@ -96,7 +96,7 @@ handle_info({tcp, Buff}, #tcp{state = #state{id = ChannelId, devaddr = DtuAddr,
|
||||
?LOG(info, "Other ~p", [Other]),
|
||||
pass
|
||||
end,
|
||||
{noreply, TCPState#tcp{buff = <<>>}};
|
||||
{noreply, TCPState#tcp{buff = <<>>, state = State#state{env = <<>>}}};
|
||||
|
||||
handle_info({deliver, _, Msg}, #tcp{state = #state{id = ChannelId} = State} = TCPState) ->
|
||||
Payload = dgiot_mqtt:get_payload(Msg),
|
||||
|
@ -81,7 +81,7 @@ get_name(ProductId, K, V) ->
|
||||
%% 发送实时卡片数据
|
||||
send_realtime_card(ProductId, DeviceId, Payload) ->
|
||||
Data = dgiot_device_card:get_card(ProductId, [Payload], DeviceId, #{}),
|
||||
Pubtopic = <<"$dg/user/", DeviceId/binary, "/realtimecard/report">>,
|
||||
Pubtopic = <<"$dg/user/realtimecard/", DeviceId/binary, "/report">>,
|
||||
dgiot_mqtt:publish(self(), Pubtopic, base64:encode(jsx:encode(#{<<"data">> => Data}))).
|
||||
|
||||
%% 发送实时组态数据
|
||||
|
Loading…
Reference in New Issue
Block a user