diff --git a/apps/iot/src/iot_host.erl b/apps/iot/src/iot_host.erl index 20dcea5..42d710a 100644 --- a/apps/iot/src/iot_host.erl +++ b/apps/iot/src/iot_host.erl @@ -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 + }. \ No newline at end of file