Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
21 changes: 21 additions & 0 deletions lib/circuits_quickstart/application.ex
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ defmodule CircuitsQuickstart.Application do

def start(_type, _args) do
if Nerves.Runtime.mix_target() != :host do
advertise_device()
setup_wifi()
Comment on lines +10 to 11
Copy link

Copilot AI Jan 23, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The project already configures mDNS services via config :mdns_lite, services: [...] (see config/target.exs:40-73). Adding another service imperatively in Application.start/2 splits configuration across places and makes it harder to audit/override. Prefer moving this service definition into the existing :mdns_lite config (and keep start/2 focused on supervision/runtime wiring).

Copilot uses AI. Check for mistakes.
end

Expand All @@ -19,6 +20,26 @@ defmodule CircuitsQuickstart.Application do
Supervisor.start_link(children, opts)
end

defp advertise_device() do
# See https://hexdocs.pm/nerves_discovery/
MdnsLite.add_mdns_service(%{
id: :nerves_device,
protocol: "nerves-device",
transport: "tcp",
port: 0,
txt_payload: [
"serial=#{Nerves.Runtime.serial_number()}",
"product=#{Nerves.Runtime.KV.get_active("nerves_fw_product")}",
"description=#{Nerves.Runtime.KV.get_active("nerves_fw_description")}",
"version=#{Nerves.Runtime.KV.get_active("nerves_fw_version")}",
"platform=#{Nerves.Runtime.KV.get_active("nerves_fw_platform")}",
"architecture=#{Nerves.Runtime.KV.get_active("nerves_fw_architecture")}",
"author=#{Nerves.Runtime.KV.get_active("nerves_fw_author")}",
"uuid=#{Nerves.Runtime.KV.get_active("nerves_fw_uuid")}"
]
})
end

defp setup_wifi() do
kv = Nerves.Runtime.KV.get_all()

Expand Down