This commit is contained in:
安礼成 2023-04-17 19:16:31 +08:00
parent 9b2f75f9d1
commit d01a44b234
2 changed files with 16 additions and 10 deletions

View File

@ -76,8 +76,14 @@ init([]) ->
case emqtt:start_link(Opts) of
{ok, ConnPid} ->
lager:debug("[iot_mqtt_subscriber] connect success, pid: ~p", [ConnPid]),
%% iot_host_sup的启动
erlang:start_timer(0, self(), subscribe_ticker),
%% host相关的全部事件
{ok, _} = emqtt:connect(ConnPid),
Topics = [
{<<"$share/nodes_group//server/register">>, 1},
{<<"$share/nodes_group//host/+/upstream">>, 1}
],
SubscribeResult = emqtt:subscribe(ConnPid, Topics),
lager:debug("[iot_mqtt_subscriber] subscribe result is: ~p", [SubscribeResult]),
{ok, #state{conn_pid = ConnPid}};
ignore ->

View File

@ -28,14 +28,14 @@ start_link() ->
init([]) ->
SupFlags = #{strategy => one_for_one, intensity => 1000, period => 3600},
ChildSpecs = [
#{
id => 'iot_host_sup',
start => {'iot_host_sup', start_link, []},
restart => permanent,
shutdown => 2000,
type => supervisor,
modules => ['iot_host_sup']
},
%#{
% id => 'iot_host_sup',
% start => {'iot_host_sup', start_link, []},
% restart => permanent,
% shutdown => 2000,
% type => supervisor,
% modules => ['iot_host_sup']
%},
#{
id => 'iot_router_sup',