This commit is contained in:
anlicheng 2023-08-09 17:16:42 +08:00
parent 8e575788f9
commit f71142b915

View File

@ -118,7 +118,6 @@ handle_request("POST", "/host/activate", _, #{<<"uuid">> := UUID, <<"auth">> :=
{ok, Pid} when is_pid(Pid) ->
lager:debug("[host_handler] activate host_id: ~p, start", [UUID]),
BinReply = jiffy:encode(#{<<"auth">> => true}, [force_utf8]),
ok = iot_host:activate(Pid, true),
case iot_host:publish_message(Pid, 8, BinReply) of
{ok, Ref} ->
@ -126,6 +125,7 @@ handle_request("POST", "/host/activate", _, #{<<"uuid">> := UUID, <<"auth">> :=
{response, Ref, Response} ->
case jiffy:decode(Response, [return_maps]) of
#{<<"code">> := 1} ->
ok = iot_host:activate(Pid, true),
{ok, 200, iot_util:json_data(<<"success">>)};
#{<<"code">> := 0, <<"message">> := Message} when is_binary(Message) ->
{ok, 200, iot_util:json_error(401, <<"操作失败: "/utf8, Message/binary>>)}