diff --git a/lib/open890/application.ex b/lib/open890/application.ex index bd661cf..09cd635 100644 --- a/lib/open890/application.ex +++ b/lib/open890/application.ex @@ -28,7 +28,7 @@ defmodule Open890.Application do {Open890.RadioConnectionSupervisor, strategy: :one_for_one, name: Open890.RadioConnectionSupervisor}, {Open890.CloudlogSupervisor, strategy: :one_for_one, name: Open890.CloudlogSupervisor}, - {Open890.UDPAudioServer, [config: udp_config]} + {Open890.UDPAudioServer, udp_config} ] # See https://hexdocs.pm/elixir/Supervisor.html diff --git a/lib/open890/udp_audio_server.ex b/lib/open890/udp_audio_server.ex index d8ae12d..51582a3 100644 --- a/lib/open890/udp_audio_server.ex +++ b/lib/open890/udp_audio_server.ex @@ -7,20 +7,12 @@ defmodule Open890.UDPAudioServer do @socket_opts [:binary, active: true] def start_link(args) do - Logger.info("UDP audio server: start_link: args: #{inspect(args)}") - - config = args |> Keyword.get(:config) - - GenServer.start_link(__MODULE__, name: __MODULE__, config: config) + GenServer.start_link(__MODULE__, args |> Keyword.merge(name: __MODULE__)) end def init(args) do - Logger.info("UDP audio server: init: args: #{inspect(args)}") - - port = args |> get_in([:config, :port]) - + port = args |> Keyword.fetch!(:port) {:ok, socket} = :gen_udp.open(port, @socket_opts) - Logger.info("UDP Audio server listening on port #{port}") {:ok, %{socket: socket}}