This commit is contained in:
anlicheng 2023-06-15 12:47:13 +08:00
parent 522c60f355
commit bd418e8e6a
2 changed files with 4 additions and 3 deletions

View File

@ -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}};

View File

@ -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}) ->