Skip to content

DevicesModule

Source: DevicesModule.h

Device

struct Device
src/core/system/DevicesModule.h:226

One discovered device, as the list serializes it.

Public Attributes

uint8_t ip = {}

char name = {}

DevType type = DevType::Generic

bool self = false

bool cached = false : restored from persistence, not yet re-heard live this session.

uint32_t lastSeenMs = 0 : [platform::millis()] at the most recent presence sighting.

uint8_t colorCount = 0 : Hue bridge only: how many of its lights are color-capable.

DevicesModule

class DevicesModule
src/core/system/DevicesModule.h:48

Inherits: MoonModule, ListSource

Discovers other devices on the LAN and presents them as a browsable list.

It covers every device on the network, this one included and marked as such. Core and domain-neutral: it finds a device, and light modules consume the list. A submodule of the network module, discovery depending on the network being up.

DevicesModule card

Public Attributes

bool wledCompatible = false : Whether to announce on the broadcast address as well as the multicast group.

Public Methods

inline void setSelfName(const char * name) : Adopt this device's own name, so its own row matches what everything else shows.

virtual inline uint8_t listRowCount() const override : How many devices are currently listed.

virtual inline void writeListRow(JsonSink & sink, uint8_t row) const override : Append one device's summary: its name, address and kind.

virtual inline void writeListRowDetail(JsonSink & sink, uint8_t row) const override : Append one device's detail, which adds its address and how long since it was heard.

virtual inline bool restoreList(const char * json, const char * key) override : Rebuild the list from the saved array, so the last-known set shows before any packet.

virtual inline void defineControls() override : Declare the compatibility toggle and the list of discovered devices.

inline void upsertHueBridge(const uint8_t ip, const char * name, uint8_t color) : Register a bridge a driver found out of band, updating its row or inserting one.

virtual inline void setup() override : Report the cached list on boot, which persistence restored before this ran.

virtual inline void prepare() override : Claim the seat that makes this the instance a driver registers through.

virtual inline void release() override : Vacate the seat and close the socket, which releases its port.

virtual inline void tick1s() override : Drain inbound packets, announce ourselves on a slow cadence, and age out the silent.

virtual inline ModuleRole role() const override : Role for type identification (no RTTI needed).

inline void injectPacketForTest(const uint8_t * data, size_t len, const uint8_t srcIp) : Feed one packet through the real pipeline, so a test needs no network.

Public Static Methods

static inline DevicesModule * active() : The one live instance, through which a light-domain driver registers what it found.

More info

Discovery is passive

Each device broadcasts a small presence packet, and this listens for them. There is no subnet sweep: a device appears when heard, and ages out when it stops. We announce ourselves on a slow cadence, so peers discover us.

Plugins are the interop seam

A foreign ecosystem hooks in as a plugin rather than a branch. Each declares its port and turns a datagram into a device kind, ours offered first. A new system is one new file, and a device found out of band registers through a seam.

Ageing out, and persistence

Each sighting is stamped, and a live-confirmed device is kept as durable history. A row restored from persistence gets a short probation, so a ghost cannot persist. The list persists, so the last-known set shows on boot before any packet arrives. This module does discovery only, never device-to-device commands.