add debug
This commit is contained in:
parent
3bdb072c70
commit
b9c3b0bdb2
@ -230,9 +230,10 @@ handle_call({publish_message, _, _, _}, _From, State = #state{uuid = UUID}) ->
|
|||||||
{reply, {error, <<"主机状态错误,发送命令失败"/utf8>>}, State};
|
{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]),
|
BinReply = jiffy:encode(#{<<"auth">> => true, <<"aes">> => Aes}, [force_utf8]),
|
||||||
ws_channel:send(ChannelPid, <<8:8, BinReply/binary>>),
|
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};
|
{reply, ok, State};
|
||||||
handle_call({activate, true}, _From, State = #state{uuid = UUID, channel_pid = undefined}) ->
|
handle_call({activate, true}, _From, State = #state{uuid = UUID, channel_pid = undefined}) ->
|
||||||
lager:debug("[iot_host] uuid: ~p, activate: true, no channel", [UUID]),
|
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 ->
|
true ->
|
||||||
BinReply = jiffy:encode(#{<<"auth">> => false}, [force_utf8]),
|
BinReply = jiffy:encode(#{<<"auth">> => false}, [force_utf8]),
|
||||||
ws_channel:send(ChannelPid, <<8:8, BinReply/binary>>),
|
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 ->
|
false ->
|
||||||
lager:debug("[iot_host] uuid: ~p, activate: false, no channel", [UUID])
|
lager:debug("[iot_host] uuid: ~p, activate: false, no channel", [UUID])
|
||||||
end,
|
end,
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user