diff --git a/config/config.exs b/config/config.exs index 43b263a..d60c2eb 100644 --- a/config/config.exs +++ b/config/config.exs @@ -16,3 +16,25 @@ config :localiserd, Localiser.Web.Endpoint, config :localiserd, :jwt_secret, System.get_env("JWT_SECRET") || "localiser_dev_jwt_secret_change_in_prod!!" + +config :mdns_lite, + hosts: ["localiser"], + ttl: 120, + services: [ + # advertise this service on the local network for auto-discovery by clients + %{ + id: :localiserd, + protocol: "localiserd", + transport: "tcp", + # todo: grab port from config + port: 4000 + }, + + # also advertise the MQTT broker for direct discovery by new sensors + %{ + id: :mqtt, + protocol: "mqtt", + transport: "tcp", + port: Application.compile_env(:localiser, :mqtt_port, 1883) + } + ] diff --git a/mix.exs b/mix.exs index 945138d..7019a5c 100644 --- a/mix.exs +++ b/mix.exs @@ -30,7 +30,8 @@ defmodule Localiserd.MixProject do {:phoenix, "~> 1.7"}, {:bandit, "~> 1.5"}, {:joken, "~> 2.6"}, - {:open_api_spex, "~> 3.21"} + {:open_api_spex, "~> 3.21"}, + {:mdns_lite, "~> 0.9"} ] end end diff --git a/mix.lock b/mix.lock index 4976729..88fe011 100644 --- a/mix.lock +++ b/mix.lock @@ -18,6 +18,7 @@ "jason": {:hex, :jason, "1.4.4", "b9226785a9aa77b6857ca22832cffa5d5011a667207eb2a0ad56adb5db443b8a", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}], "hexpm", "c5eb0cab91f094599f94d55bc63409236a8ec69a21a67814529e8d5f6cc90b3b"}, "joken": {:hex, :joken, "2.6.2", "5daaf82259ca603af4f0b065475099ada1b2b849ff140ccd37f4b6828ca6892a", [:mix], [{:jose, "~> 1.11.10", [hex: :jose, repo: "hexpm", optional: false]}], "hexpm", "5134b5b0a6e37494e46dbf9e4dad53808e5e787904b7c73972651b51cce3d72b"}, "jose": {:hex, :jose, "1.11.12", "06e62b467b61d3726cbc19e9b5489f7549c37993de846dfb3ee8259f9ed208b3", [:mix, :rebar3], [], "hexpm", "31e92b653e9210b696765cdd885437457de1add2a9011d92f8cf63e4641bab7b"}, + "mdns_lite": {:hex, :mdns_lite, "0.9.1", "fb305081d01aa62d38d86a4e467e9b7eb217aa68d62c22b111105170ca7f198f", [:mix], [{:igniter, "~> 0.5", [hex: :igniter, repo: "hexpm", optional: true]}, {:vintage_net, "~> 0.7", [hex: :vintage_net, repo: "hexpm", optional: true]}], "hexpm", "4f5ae0c6cc69fcc3adadf68bfd54abfc5a284defa703d6faefe40ade2145a601"}, "mime": {:hex, :mime, "2.0.7", "b8d739037be7cd402aee1ba0306edfdef982687ee7e9859bee6198c1e7e2f128", [:mix], [], "hexpm", "6171188e399ee16023ffc5b76ce445eb6d9672e2e241d2df6050f3c771e80ccd"}, "open_api_spex": {:hex, :open_api_spex, "3.22.2", "0b3c4f572ee69cb6c936abf426b9d84d8eebd34960871fd77aead746f0d69cb0", [:mix], [{:decimal, "~> 1.0 or ~> 2.0", [hex: :decimal, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:plug, "~> 1.7", [hex: :plug, repo: "hexpm", optional: false]}, {:poison, "~> 3.0 or ~> 4.0 or ~> 5.0 or ~> 6.0", [hex: :poison, repo: "hexpm", optional: true]}, {:ymlr, "~> 2.0 or ~> 3.0 or ~> 4.0 or ~> 5.0", [hex: :ymlr, repo: "hexpm", optional: true]}], "hexpm", "0a4fc08472d75e9cfe96e0748c6b1565b3b4398f97bf43fcce41b41b6fd3fb33"}, "phoenix": {:hex, :phoenix, "1.8.5", "919db335247e6d4891764dc3063415b0d2457641c5f9b3751b5df03d8e20bbcf", [:mix], [{:bandit, "~> 1.0", [hex: :bandit, repo: "hexpm", optional: true]}, {:jason, "~> 1.0", [hex: :jason, repo: "hexpm", optional: true]}, {:phoenix_pubsub, "~> 2.1", [hex: :phoenix_pubsub, repo: "hexpm", optional: false]}, {:phoenix_template, "~> 1.0", [hex: :phoenix_template, repo: "hexpm", optional: false]}, {:phoenix_view, "~> 2.0", [hex: :phoenix_view, repo: "hexpm", optional: true]}, {:plug, "~> 1.14", [hex: :plug, repo: "hexpm", optional: false]}, {:plug_cowboy, "~> 2.7", [hex: :plug_cowboy, repo: "hexpm", optional: true]}, {:plug_crypto, "~> 1.2 or ~> 2.0", [hex: :plug_crypto, repo: "hexpm", optional: false]}, {:telemetry, "~> 0.4 or ~> 1.0", [hex: :telemetry, repo: "hexpm", optional: false]}, {:websock_adapter, "~> 0.5.3", [hex: :websock_adapter, repo: "hexpm", optional: false]}], "hexpm", "83b2bb125127e02e9f475c8e3e92736325b5b01b0b9b05407bcb4083b7a32485"},