fix host
This commit is contained in:
parent
522c60f355
commit
bd418e8e6a
@ -114,7 +114,8 @@ handle_request("POST", "/host/activate", _, #{<<"uuid">> := UUID, <<"auth">> :=
|
||||
{ok, Pid} when is_pid(Pid) ->
|
||||
lager:debug("[host_handler] activate host_id: ~p, start", [UUID]),
|
||||
%% 下发指令
|
||||
{ok, Assoc, Aes, ReplyTopic} = iot_host:make_assoc(Pid),
|
||||
{ok, Assoc, Aes} = iot_host:make_assoc(Pid),
|
||||
ReplyTopic = iot_host:upstream_topic(UUID),
|
||||
Reply = case Auth of
|
||||
true ->
|
||||
#{<<"auth">> => true, <<"aes">> => Aes, <<"reply">> => #{<<"topic">> => ReplyTopic, <<"assoc">> => Assoc}};
|
||||
|
||||
@ -96,7 +96,7 @@ reload(Pid) when is_pid(Pid) ->
|
||||
get_aes(Pid) when is_pid(Pid) ->
|
||||
gen_server:call(Pid, get_aes).
|
||||
|
||||
-spec make_assoc(Pid :: pid()) -> {ok, Assoc :: binary(), Aes :: binary(), Topic :: binary()}.
|
||||
-spec make_assoc(Pid :: pid()) -> {ok, Assoc :: binary(), Aes :: binary()}.
|
||||
make_assoc(Pid) when is_pid(Pid) ->
|
||||
gen_server:call(Pid, {make_assoc, self()}).
|
||||
|
||||
@ -170,7 +170,7 @@ handle_call({make_assoc, ReceivePid}, _From, State = #state{uuid = UUID, increme
|
||||
BinIncrementId = erlang:integer_to_binary(IncrementId),
|
||||
Assoc = <<UUID/binary, ":assoc:", BinIncrementId/binary>>,
|
||||
|
||||
{reply, {ok, Assoc, Aes, upstream_topic(UUID)}, State#state{assoc_map = maps:put(Assoc, ReceivePid, AssocMap), increment_id = IncrementId + 1}};
|
||||
{reply, {ok, Assoc, Aes}, State#state{assoc_map = maps:put(Assoc, ReceivePid, AssocMap), increment_id = IncrementId + 1}};
|
||||
|
||||
%% 重新加载主机信息
|
||||
handle_call(reload, _From, State = #state{uuid = UUID}) ->
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user