add debug

This commit is contained in:
anlicheng 2023-09-19 11:01:22 +08:00
parent f19faae471
commit 455961ef86

View File

@ -226,7 +226,8 @@ handle_call({publish_message, ReceiverPid, CommandType, Command}, _From, State =
{reply, {ok, Ref}, State};
handle_call({publish_message, _, _, _}, _From, State) ->
handle_call({publish_message, _, _, _}, _From, State = #state{uuid = UUID}) ->
lager:debug("[iot_host] uuid: ~p, publish_message invalid state: ~p", [UUID, state_map(State)]),
{reply, {error, <<"主机状态错误,发送命令失败"/utf8>>}, State};
%%
@ -544,3 +545,16 @@ report_event(UUID, NewStatus) when is_binary(UUID), is_integer(NewStatus) ->
}],
iot_router:route(UUID, FieldsList, Timestamp),
lager:debug("[iot_host] host_uuid: ~p, route fields: ~p", [UUID, FieldsList]).
%% state转换成map
state_map(#state{host_id = HostId, uuid = UUID, aes = Aes, has_session = HasSession, heartbeat_counter = HeartbeatCounter, channel_pid = ChannelPid, monitor_ref = MonitorRef, metrics = Metrics}) ->
#{
host_id => HostId,
uuid => UUID,
aes => Aes,
has_session => HasSession,
heartbeat_counter => HeartbeatCounter,
channel_pid => ChannelPid,
monitor_ref => MonitorRef,
metrics => Metrics
}.