Skip to content

Commit

Permalink
Shuffle more config around
Browse files Browse the repository at this point in the history
  • Loading branch information
tonyc committed Apr 6, 2024
1 parent d6d51e1 commit 24a6263
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 11 deletions.
2 changes: 1 addition & 1 deletion lib/open890/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
12 changes: 2 additions & 10 deletions lib/open890/udp_audio_server.ex
Original file line number Diff line number Diff line change
Expand Up @@ -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}}
Expand Down

0 comments on commit 24a6263

Please sign in to comment.