diff --git a/apps/iot/src/http_handler/host_handler.erl b/apps/iot/src/http_handler/host_handler.erl index 8757eac..5265cdc 100644 --- a/apps/iot/src/http_handler/host_handler.erl +++ b/apps/iot/src/http_handler/host_handler.erl @@ -144,24 +144,19 @@ handle_request("POST", "/host/activate", _, #{<<"uuid">> := UUID, <<"auth">> := {ok, 200, iot_util:json_error(400, <<"host not found">>)}; {ok, Pid} when is_pid(Pid) -> ok = iot_host:activate(Pid, false), - %% 激活的话不管是否存在会话都需要通知 - case iot_host:has_session(Pid) of - true -> - lager:debug("[host_handler] activate host_id: ~p, start", [UUID]), - BinReply = jiffy:encode(#{<<"auth">> => false}, [force_utf8]), - case iot_host:publish_message(Pid, 8, BinReply) of - {ok, Ref} -> - receive - {response, Ref, Response} -> - lager:debug("[iot_host_handler] host_id uuid: ~p, publish topic success, get response: ~p", [Response]) - 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]) + + lager:debug("[host_handler] activate host_id: ~p, start", [UUID]), + BinReply = jiffy:encode(#{<<"auth">> => false}, [force_utf8]), + case iot_host:publish_message(Pid, 8, BinReply) of + {ok, Ref} -> + receive + {response, Ref, Response} -> + lager:debug("[iot_host_handler] host_id uuid: ~p, publish topic success, get response: ~p", [Response]) + after Timeout * 1000 -> + lager:debug("[iot_host_handler] host_id uuid: ~p, publish topic success, but get ack timeout", [UUID]) end; - false -> - ok + {error, Reason} -> + lager:debug("[iot_host] host_id uuid: ~p, publish command get error: ~p", [UUID, Reason]) end, {ok, 200, iot_util:json_data(<<"success">>)} end;