This commit is contained in:
安礼成 2023-03-06 16:52:05 +08:00
parent d44889aff2
commit 02cf888c32
3 changed files with 8 additions and 7 deletions

View File

@ -8,6 +8,7 @@
-behaviour(application).
-export([start/2, stop/1]).
-export([start_http_server/0]).
start(_StartType, _StartArgs) ->
io:setopts([{encoding, unicode}]),
@ -19,7 +20,7 @@ start(_StartType, _StartArgs) ->
%%
erlang:system_flag(fullsweep_after, 16),
start_http_server(),
%start_http_server(),
iot_sup:start_link().

View File

@ -48,12 +48,12 @@ start_link() ->
{ok, State :: #state{}} | {ok, State :: #state{}, timeout() | hibernate} |
{stop, Reason :: term()} | ignore).
init([]) ->
{ok, ServerOpts} = application:get_env(iot, emqx_server),
{ok, ConnPid} = emqtt:start_link([{clientid, iot_emqtt_client}, {owner, self()}|ServerOpts]),
{ok, _Props} = emqtt:connect(ConnPid),
%{ok, ServerOpts} = application:get_env(iot, emqx_server),
%{ok, ConnPid} = emqtt:start_link([{clientid, iot_emqtt_client}, {owner, self()}|ServerOpts]),
%{ok, _Props} = emqtt:connect(ConnPid),
SubOpts = [{qos, 1}],
{ok, _Props, _ReasonCodes} = emqtt:subscribe(ConnPid, #{}, [{<<"hello">>, SubOpts}]),
%SubOpts = [{qos, 1}],
%{ok, _Props, _ReasonCodes} = emqtt:subscribe(ConnPid, #{}, [{<<"hello">>, SubOpts}]),
{ok, #state{}}.

View File

@ -97,7 +97,7 @@ change_status(HostId, Status) when is_binary(HostId), is_integer(Status) ->
{error, Reason}
end.
-spec activate(HostId :: binary()) -> ok | {error, Reason}.
-spec activate(HostId :: binary()) -> ok | {error, Reason :: any()}.
activate(HostId) when is_binary(HostId) ->
Fun = fun() ->
case mnesia:read(host, HostId) of