diff --git a/src/host/iot_host.erl b/src/host/iot_host.erl index 25c7a8e..b156aba 100644 --- a/src/host/iot_host.erl +++ b/src/host/iot_host.erl @@ -25,7 +25,7 @@ -export([start_link/2, get_name/1, get_alias_name/1, get_pid/1, handle/2, activate/2]). -export([get_metric/1, get_status/1, kill/1]). %% 通讯相关 --export([pub/4, attach_channel/2, command/2]). +-export([pub/4, attach_channel/2]). -export([deploy_container/3, start_container/2, stop_container/2, remove_container/2, kill_container/2, config_container/3, get_containers/1, await_reply/3]). -export([heartbeat/1]). @@ -144,10 +144,6 @@ await_reply(Pid, Ref, Timeout) when is_pid(Pid), is_reference(Ref), is_integer(T pub(Pid, Topic, Qos, Content) when is_pid(Pid), is_binary(Topic), is_integer(Qos), is_binary(Content) -> gen_statem:call(Pid, {pub, Topic, Qos, Content}). --spec command(Pid :: pid(), Command :: message_pb:'CastFrame.Command'()) -> ok | {error, Reason :: any()}. -command(Pid, Command) when is_pid(Pid) -> - gen_statem:call(Pid, {command, Command}). - -spec heartbeat(Pid :: pid()) -> no_return(). heartbeat(undefined) -> ok; @@ -247,19 +243,6 @@ handle_event({call, From}, {pub, Topic, Qos, Content}, ?STATE_ACTIVATED, State = {keep_state, State, [{reply, From, {error, <<"主机离线,发送失败"/utf8>>}}]} end; -%% 发送指令时 -handle_event({call, From}, {command, Command}, ?STATE_ACTIVATED, State = #state{uuid = UUID, channel_pid = ChannelPid, has_session = HasSession}) -> - case HasSession andalso is_pid(ChannelPid) of - true -> - logger:debug("[iot_host] host: ~p, command: ~p", [UUID, Command]), - %% 通过websocket发送请求 - ssl_channel:command(ChannelPid, Command), - {keep_state, State, [{reply, From, ok}]}; - false -> - logger:debug("[iot_host] host: ~p, command: ~p, invalid state: ~p", [UUID, Command, state_map(State)]), - {keep_state, State, [{reply, From, {error, <<"主机离线,发送指令失败"/utf8>>}}]} - end; - %% 激活主机 handle_event({call, From}, {activate, true}, _, State = #state{uuid = UUID, channel_pid = ChannelPid}) -> case is_pid(ChannelPid) of