From d034cefbadc28e989d6c54e7b08cf02f833fafe4 Mon Sep 17 00:00:00 2001 From: Frank Hunleth Date: Fri, 23 Jan 2026 10:04:04 -0500 Subject: [PATCH] Advertise device and firmware info on the network --- lib/circuits_quickstart/application.ex | 21 +++++++++++++++++++++ 1 file changed, 21 insertions(+) diff --git a/lib/circuits_quickstart/application.ex b/lib/circuits_quickstart/application.ex index f8d66eb..d6d806c 100644 --- a/lib/circuits_quickstart/application.ex +++ b/lib/circuits_quickstart/application.ex @@ -7,6 +7,7 @@ defmodule CircuitsQuickstart.Application do def start(_type, _args) do if Nerves.Runtime.mix_target() != :host do + advertise_device() setup_wifi() end @@ -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()