From 747cc8583d10b39d418d82070c12447aa5373a9c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E7=A4=BC=E6=88=90?= Date: Mon, 17 Apr 2023 19:22:28 +0800 Subject: [PATCH] fix subscriber --- apps/iot/src/iot_commander.erl | 13 +++++++++++++ apps/iot/src/iot_mqtt_subscriber.erl | 12 ------------ 2 files changed, 13 insertions(+), 12 deletions(-) create mode 100644 apps/iot/src/iot_commander.erl diff --git a/apps/iot/src/iot_commander.erl b/apps/iot/src/iot_commander.erl new file mode 100644 index 0000000..d38e6f3 --- /dev/null +++ b/apps/iot/src/iot_commander.erl @@ -0,0 +1,13 @@ +%%%------------------------------------------------------------------- +%%% @author licheng5 +%%% @copyright (C) 2023, +%%% @doc +%%% 用来处理和封装通过mqtt协议下发的命令 +%%% @end +%%% Created : 17. 4月 2023 19:20 +%%%------------------------------------------------------------------- +-module(iot_commander). +-author("licheng5"). + +%% API +-export([]). diff --git a/apps/iot/src/iot_mqtt_subscriber.erl b/apps/iot/src/iot_mqtt_subscriber.erl index 4190cf8..dd8aebe 100644 --- a/apps/iot/src/iot_mqtt_subscriber.erl +++ b/apps/iot/src/iot_mqtt_subscriber.erl @@ -122,18 +122,6 @@ handle_cast(_Request, State = #state{}) -> {noreply, NewState :: #state{}} | {noreply, NewState :: #state{}, timeout() | hibernate} | {stop, Reason :: term(), NewState :: #state{}}). -%% 处理topic的订阅事件 -handle_info({timeout, _, subscribe_ticker}, State = #state{conn_pid = ConnPid}) -> - %% 监听和host相关的全部事件 - {ok, _} = emqtt:connect(ConnPid), - Topics = [ - {<<"$share/nodes//server/register">>, 1} - ], - SubscribeResult = emqtt:subscribe(ConnPid, Topics), - lager:debug("[iot_mqtt_subscriber] subscribe result is: ~p", [SubscribeResult]), - - {noreply, State#state{conn_pid = ConnPid}}; - handle_info({disconnect, ReasonCode, Properties}, State = #state{}) -> lager:debug("[iot_mqtt_subscriber] Recv a DISONNECT packet - ReasonCode: ~p, Properties: ~p", [ReasonCode, Properties]), {stop, disconnected, State};