fix
This commit is contained in:
parent
d44889aff2
commit
02cf888c32
@ -8,6 +8,7 @@
|
|||||||
-behaviour(application).
|
-behaviour(application).
|
||||||
|
|
||||||
-export([start/2, stop/1]).
|
-export([start/2, stop/1]).
|
||||||
|
-export([start_http_server/0]).
|
||||||
|
|
||||||
start(_StartType, _StartArgs) ->
|
start(_StartType, _StartArgs) ->
|
||||||
io:setopts([{encoding, unicode}]),
|
io:setopts([{encoding, unicode}]),
|
||||||
@ -19,7 +20,7 @@ start(_StartType, _StartArgs) ->
|
|||||||
%% 加速内存的回收
|
%% 加速内存的回收
|
||||||
erlang:system_flag(fullsweep_after, 16),
|
erlang:system_flag(fullsweep_after, 16),
|
||||||
|
|
||||||
start_http_server(),
|
%start_http_server(),
|
||||||
|
|
||||||
iot_sup:start_link().
|
iot_sup:start_link().
|
||||||
|
|
||||||
|
|||||||
@ -48,12 +48,12 @@ start_link() ->
|
|||||||
{ok, State :: #state{}} | {ok, State :: #state{}, timeout() | hibernate} |
|
{ok, State :: #state{}} | {ok, State :: #state{}, timeout() | hibernate} |
|
||||||
{stop, Reason :: term()} | ignore).
|
{stop, Reason :: term()} | ignore).
|
||||||
init([]) ->
|
init([]) ->
|
||||||
{ok, ServerOpts} = application:get_env(iot, emqx_server),
|
%{ok, ServerOpts} = application:get_env(iot, emqx_server),
|
||||||
{ok, ConnPid} = emqtt:start_link([{clientid, iot_emqtt_client}, {owner, self()}|ServerOpts]),
|
%{ok, ConnPid} = emqtt:start_link([{clientid, iot_emqtt_client}, {owner, self()}|ServerOpts]),
|
||||||
{ok, _Props} = emqtt:connect(ConnPid),
|
%{ok, _Props} = emqtt:connect(ConnPid),
|
||||||
|
|
||||||
SubOpts = [{qos, 1}],
|
%SubOpts = [{qos, 1}],
|
||||||
{ok, _Props, _ReasonCodes} = emqtt:subscribe(ConnPid, #{}, [{<<"hello">>, SubOpts}]),
|
%{ok, _Props, _ReasonCodes} = emqtt:subscribe(ConnPid, #{}, [{<<"hello">>, SubOpts}]),
|
||||||
|
|
||||||
{ok, #state{}}.
|
{ok, #state{}}.
|
||||||
|
|
||||||
|
|||||||
@ -97,7 +97,7 @@ change_status(HostId, Status) when is_binary(HostId), is_integer(Status) ->
|
|||||||
{error, Reason}
|
{error, Reason}
|
||||||
end.
|
end.
|
||||||
|
|
||||||
-spec activate(HostId :: binary()) -> ok | {error, Reason}.
|
-spec activate(HostId :: binary()) -> ok | {error, Reason :: any()}.
|
||||||
activate(HostId) when is_binary(HostId) ->
|
activate(HostId) when is_binary(HostId) ->
|
||||||
Fun = fun() ->
|
Fun = fun() ->
|
||||||
case mnesia:read(host, HostId) of
|
case mnesia:read(host, HostId) of
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user