NervesGate.Equipment (nerves_gate v0.1.0)

Copy Markdown

Equipment observations and local labels for the confirmed equipment subnet.

Commands

label/3 saves a label and returns :ok after persistence, or {:error, reason}. Use NervesGate.equipment_scan/1 for an active scan: Network reserves its LAN worker so scanning cannot overlap network reconfiguration.

Queries and notifications

status/1 returns the scope, entries, scan progress and errors. Entries and labels are capped at 256 each; observations are not proof of reachability. observe/1 subscribes the caller to inventory changes; reread status afterward. The optional server argument defaults to this module.

Passive discovery failures for a confirmed scope set :equipment_discovery_unavailable. A successful observation (even an empty inventory) or removing the equipment configuration clears it. Scan results, label commands and temporarily unknown network state do not clear that fault.

Summary

Functions

Returns a specification to start this module under a supervisor.

Save a label for an ID from status entries. At most 64 characters; empty text removes it.

Subscribe the caller to inventory-change hints; read status to obtain current entries.

Read scoped entries, last scan, operation and errors. Does not initiate a scan.

Functions

child_spec(init_arg)

Returns a specification to start this module under a supervisor.

See Supervisor.

label(id, value, server \\ __MODULE__)

@spec label(String.t(), String.t(), GenServer.server()) :: :ok | {:error, term()}

Save a label for an ID from status entries. At most 64 characters; empty text removes it.

observe(server \\ __MODULE__)

@spec observe(GenServer.server()) :: :ok | {:error, :unavailable}

Subscribe the caller to inventory-change hints; read status to obtain current entries.

status(server \\ __MODULE__)

@spec status(GenServer.server()) :: map()

Read scoped entries, last scan, operation and errors. Does not initiate a scan.