diff --git a/apps/iot/src/iot_host.erl b/apps/iot/src/iot_host.erl index 699fa97..d561002 100644 --- a/apps/iot/src/iot_host.erl +++ b/apps/iot/src/iot_host.erl @@ -230,9 +230,10 @@ handle_call({publish_message, _, _, _}, _From, State = #state{uuid = UUID}) -> {reply, {error, <<"主机状态错误,发送命令失败"/utf8>>}, State}; %% 激活主机 -handle_call({activate, true}, _From, State = #state{aes = Aes, channel_pid = ChannelPid}) when is_pid(ChannelPid) -> +handle_call({activate, true}, _From, State = #state{uuid = UUID, aes = Aes, channel_pid = ChannelPid}) when is_pid(ChannelPid) -> BinReply = jiffy:encode(#{<<"auth">> => true, <<"aes">> => Aes}, [force_utf8]), ws_channel:send(ChannelPid, <<8:8, BinReply/binary>>), + lager:debug("[iot_host] uuid: ~p, activate: true, will send message: ~p", [UUID, BinReply]), {reply, ok, State}; handle_call({activate, true}, _From, State = #state{uuid = UUID, channel_pid = undefined}) -> lager:debug("[iot_host] uuid: ~p, activate: true, no channel", [UUID]), @@ -244,7 +245,8 @@ handle_call({activate, false}, _From, State = #state{uuid = UUID, host_id = Host true -> BinReply = jiffy:encode(#{<<"auth">> => false}, [force_utf8]), ws_channel:send(ChannelPid, <<8:8, BinReply/binary>>), - ws_channel:stop(ChannelPid, closed); + ws_channel:stop(ChannelPid, closed), + lager:debug("[iot_host] uuid: ~p, activate: false, will send message: ~p", [UUID, BinReply]); false -> lager:debug("[iot_host] uuid: ~p, activate: false, no channel", [UUID]) end,