diff --git a/apps/iot/src/http_handler/http_host_handler.erl b/apps/iot/src/http_handler/http_host_handler.erl index 9d351fb..395e32f 100644 --- a/apps/iot/src/http_handler/http_host_handler.erl +++ b/apps/iot/src/http_handler/http_host_handler.erl @@ -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}}; diff --git a/apps/iot/src/iot_host.erl b/apps/iot/src/iot_host.erl index 42402a9..894a1a7 100644 --- a/apps/iot/src/iot_host.erl +++ b/apps/iot/src/iot_host.erl @@ -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 = <>, - {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}) ->