fix subscriber

This commit is contained in:
安礼成 2023-04-17 19:22:28 +08:00
parent d01a44b234
commit 747cc8583d
2 changed files with 13 additions and 12 deletions

View 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([]).

View File

@ -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};