diff --git a/apps/iot/src/endpoint/iot_zd_endpoint.erl b/apps/iot/src/endpoint/iot_zd_endpoint.erl index a4c0d96..2126fee 100644 --- a/apps/iot/src/endpoint/iot_zd_endpoint.erl +++ b/apps/iot/src/endpoint/iot_zd_endpoint.erl @@ -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) -> diff --git a/apps/iot/src/postman/mqtt_postman.erl b/apps/iot/src/postman/mqtt_postman.erl index e73bb1f..d24f31e 100644 --- a/apps/iot/src/postman/mqtt_postman.erl +++ b/apps/iot/src/postman/mqtt_postman.erl @@ -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], []). %%%===================================================================