This commit is contained in:
安礼成 2023-03-30 20:33:58 +08:00
parent 359c13924f
commit 3d8fccd0dc
3 changed files with 10 additions and 9 deletions

View File

@ -49,7 +49,7 @@ start_link() ->
{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, ConnPid} = emqtt:start_link([{clientid, iot_emqtt_client}, {owner, self()}|ServerOpts]),
%{ok, _Props} = emqtt:connect(ConnPid),
%SubOpts = [{qos, 1}],

View File

@ -52,19 +52,20 @@ init([Host]) ->
lager:debug("[iot_host] host is: ~p", [Host]),
%% emqx服务器的连接
{ok, Props} = application:get_env(iot, emqx_server),
Host = proplists:get_value(host, Props),
Port = proplists:get_value(port, Props, 18080),
EMQXHost = proplists:get_value(host, Props),
EMQXPort = proplists:get_value(port, Props, 18080),
Username = proplists:get_value(username, Props),
Password = proplists:get_value(password, Props),
RetryInterval = proplists:get_value(retry_interval, Props, 5),
Keepalive = proplists:get_value(keepalive, Props, 86400),
Opts = [
{host, Host},
{port, Port},
{host, EMQXHost},
{port, EMQXPort},
{owner, self()},
{tcp_opts, []},
{username, Username},
{password, Password},
{keepalive, 'Keepalive'},
{keepalive, Keepalive},
{retry_interval, RetryInterval}
],

View File

@ -9,12 +9,12 @@
%% 目标服务器地址
{emqx_server, [
{host, "103.113.157.7"},
{port, 18080},
{host, {103, 113, 157, 7}},
{port, 1883},
{tcp_opts, []},
{username, "test"},
{password, "test1234"},
{keepalive, 'Keepalive'},
{keepalive, 86400},
{retry_interval, 5}
]}