fix host mocker
This commit is contained in:
parent
3b9be77e43
commit
01b4d5c207
@ -185,6 +185,7 @@ handle_info({publish, #{payload := Payload, qos := Qos, topic := FromTopic}},
|
||||
%% 触发inform上传
|
||||
erlang:start_timer(?TICKER_INTERVAL, self(), inform_ticker),
|
||||
erlang:start_timer(?TICKER_INTERVAL, self(), feedback_ticker),
|
||||
erlang:start_timer(?TICKER_INTERVAL, self(), feedback_step_ticker),
|
||||
|
||||
{noreply, State#state{aes = Aes}};
|
||||
_ ->
|
||||
@ -344,9 +345,27 @@ handle_info({timeout, _, feedback_ticker}, State = #state{aes = Aes, topic = Top
|
||||
{ok, Ref} = iot_mqtt_publisher:publish(Topic, <<?METHOD_FEEDBACK_RESULT:8, EncInfo/binary>>, 1),
|
||||
receive
|
||||
{ok, Ref, PacketId} ->
|
||||
lager:debug("[host_mocker] send inform success, packet_id: ~p", [PacketId]);
|
||||
lager:debug("[host_mocker] send feedback success, packet_id: ~p", [PacketId]);
|
||||
{error, Reason} ->
|
||||
lager:debug("[host_mocker] send inform failed, reason: ~p", [Reason])
|
||||
lager:debug("[host_mocker] send feedback failed, reason: ~p", [Reason])
|
||||
end,
|
||||
|
||||
{noreply, State};
|
||||
|
||||
%% 上传微服务的feedback_result信息
|
||||
handle_info({timeout, _, feedback_step_ticker}, State = #state{aes = Aes, topic = Topic}) ->
|
||||
Info = jiffy:encode(#{
|
||||
<<"task_id">> => 1,
|
||||
<<"code">> => 2
|
||||
}, [force_utf8]),
|
||||
EncInfo = iot_cipher_aes:encrypt(Aes, Info),
|
||||
|
||||
{ok, Ref} = iot_mqtt_publisher:publish(Topic, <<?METHOD_FEEDBACK_STEP:8, EncInfo/binary>>, 1),
|
||||
receive
|
||||
{ok, Ref, PacketId} ->
|
||||
lager:debug("[host_mocker] send feedback step success, packet_id: ~p", [PacketId]);
|
||||
{error, Reason} ->
|
||||
lager:debug("[host_mocker] send feedback step failed, reason: ~p", [Reason])
|
||||
end,
|
||||
|
||||
{noreply, State};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user