fix mqtt topic

This commit is contained in:
anlicheng 2024-06-22 14:19:06 +08:00
parent 84ceab0b5d
commit c8bf170562
2 changed files with 3 additions and 3 deletions

View File

@ -206,7 +206,7 @@ create_postman(Opts) ->
Port = proplists:get_value(port, Opts),
Username = proplists:get_value(username, Opts),
Password = proplists:get_value(password, Opts),
Topic = proplists:get_value(topic, Opts),
Topic0 = proplists:get_value(topic, Opts),
Qos = proplists:get_value(qos, Opts),
Node = atom_to_binary(node()),
@ -225,7 +225,7 @@ create_postman(Opts) ->
{retry_interval, 5000}
],
mqtt_postman:start_link(PostmanOpts, Topic, Qos).
mqtt_postman:start_link(PostmanOpts, list_to_binary(Topic0), Qos).
-spec do_post(PostmanPid :: pid(), NorthData :: #north_data{}) -> no_return().
do_post(PostmanPid, #north_data{id = Id, location_code = LocationCode, dynamic_location_code = DynamicLocationCode, fields = Fields, timestamp = Timestamp}) when is_pid(PostmanPid) ->

View File

@ -32,7 +32,7 @@
%% @doc Spawns the server and registers the local name (unique)
-spec(start_link(Opts :: list(), Topic :: binary(), Qos :: integer()) ->
{ok, Pid :: pid()} | ignore | {error, Reason :: term()}).
start_link(Opts, Topic, Qos) when is_list(Opts), is_binary(Topic), Qos == 0; Qos == 1; Qos == 2 ->
start_link(Opts, Topic, Qos) when is_list(Opts) andalso is_binary(Topic) andalso (Qos == 0 orelse Qos == 1 orelse Qos == 2) ->
gen_server:start_link(?MODULE, [Opts, Topic, Qos], []).
%%%===================================================================