This commit is contained in:
anlicheng 2023-08-09 17:51:58 +08:00
parent dc7aa27e4e
commit 16882a038e

View File

@ -144,24 +144,19 @@ handle_request("POST", "/host/activate", _, #{<<"uuid">> := UUID, <<"auth">> :=
{ok, 200, iot_util:json_error(400, <<"host not found">>)}; {ok, 200, iot_util:json_error(400, <<"host not found">>)};
{ok, Pid} when is_pid(Pid) -> {ok, Pid} when is_pid(Pid) ->
ok = iot_host:activate(Pid, false), ok = iot_host:activate(Pid, false),
%%
case iot_host:has_session(Pid) of lager:debug("[host_handler] activate host_id: ~p, start", [UUID]),
true -> BinReply = jiffy:encode(#{<<"auth">> => false}, [force_utf8]),
lager:debug("[host_handler] activate host_id: ~p, start", [UUID]), case iot_host:publish_message(Pid, 8, BinReply) of
BinReply = jiffy:encode(#{<<"auth">> => false}, [force_utf8]), {ok, Ref} ->
case iot_host:publish_message(Pid, 8, BinReply) of receive
{ok, Ref} -> {response, Ref, Response} ->
receive lager:debug("[iot_host_handler] host_id uuid: ~p, publish topic success, get response: ~p", [Response])
{response, Ref, Response} -> after Timeout * 1000 ->
lager:debug("[iot_host_handler] host_id uuid: ~p, publish topic success, get response: ~p", [Response]) lager:debug("[iot_host_handler] host_id uuid: ~p, publish topic success, but get ack timeout", [UUID])
after Timeout * 1000 ->
lager:debug("[iot_host_handler] host_id uuid: ~p, publish topic success, but get ack timeout", [UUID])
end;
{error, Reason} ->
lager:debug("[iot_host] host_id uuid: ~p, publish command get error: ~p", [UUID, Reason])
end; end;
false -> {error, Reason} ->
ok lager:debug("[iot_host] host_id uuid: ~p, publish command get error: ~p", [UUID, Reason])
end, end,
{ok, 200, iot_util:json_data(<<"success">>)} {ok, 200, iot_util:json_data(<<"success">>)}
end; end;