add debug

This commit is contained in:
anlicheng 2023-09-19 15:14:07 +08:00
parent 3bdb072c70
commit b9c3b0bdb2

View File

@ -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,