fix subscriber
This commit is contained in:
parent
d01a44b234
commit
747cc8583d
13
apps/iot/src/iot_commander.erl
Normal file
13
apps/iot/src/iot_commander.erl
Normal file
@ -0,0 +1,13 @@
|
||||
%%%-------------------------------------------------------------------
|
||||
%%% @author licheng5
|
||||
%%% @copyright (C) 2023, <COMPANY>
|
||||
%%% @doc
|
||||
%%% 用来处理和封装通过mqtt协议下发的命令
|
||||
%%% @end
|
||||
%%% Created : 17. 4月 2023 19:20
|
||||
%%%-------------------------------------------------------------------
|
||||
-module(iot_commander).
|
||||
-author("licheng5").
|
||||
|
||||
%% API
|
||||
-export([]).
|
||||
@ -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};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user