From 02cf888c32d9f0cef84f7eba4ec5b8dfd3731fce Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E5=AE=89=E7=A4=BC=E6=88=90?= Date: Mon, 6 Mar 2023 16:52:05 +0800 Subject: [PATCH] fix --- apps/iot/src/iot_app.erl | 3 ++- apps/iot/src/iot_emqtt_client.erl | 10 +++++----- apps/iot/src/model/host_model.erl | 2 +- 3 files changed, 8 insertions(+), 7 deletions(-) diff --git a/apps/iot/src/iot_app.erl b/apps/iot/src/iot_app.erl index a99c2d2..a647c10 100644 --- a/apps/iot/src/iot_app.erl +++ b/apps/iot/src/iot_app.erl @@ -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(). diff --git a/apps/iot/src/iot_emqtt_client.erl b/apps/iot/src/iot_emqtt_client.erl index 30667bf..60a53f6 100644 --- a/apps/iot/src/iot_emqtt_client.erl +++ b/apps/iot/src/iot_emqtt_client.erl @@ -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{}}. diff --git a/apps/iot/src/model/host_model.erl b/apps/iot/src/model/host_model.erl index 9c940d1..284e281 100644 --- a/apps/iot/src/model/host_model.erl +++ b/apps/iot/src/model/host_model.erl @@ -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