DeviceDiscoveryModule¶
Discovers other projectMM nodes on the local network via UDP broadcast and lists them in the UI.
Introduced in Release 4, Sprint 1B.
What it does¶
On startup the module binds a UDP socket on port 23452 and immediately broadcasts its own presence. It continues broadcasting every broadcast_interval milliseconds. Incoming packets from other projectMM nodes are parsed and displayed as device_N controls — up to 8 devices.
Each entry shows: MM-70BC @ 192.168.8.156 (v1.3.0)
Self-packets (same device_name as the local node) are silently filtered out.
Protocol¶
| Field | Value |
|---|---|
| Transport | UDP broadcast to 255.255.255.255 |
| Port | 23452 |
| Packet format | {"device":"MM-70BC","version":"1.3.0"} |
| Sender IP | Read from the UDP source address — not included in the payload |
Parent¶
NetworkModule — wire via setInput("network"). The parent's deviceName() is used as the source identifier in outgoing packets.
Controls¶
| Key | Type | Description |
|---|---|---|
broadcast_interval |
range (1000–30000 ms) | How often to broadcast presence |
status |
display | "N device(s) found" |
device_1 … device_8 |
display | Each discovered peer: name @ ip (version) |
Health report¶
devices=2 port=23452
Platform support¶
| Platform | Status |
|---|---|
| PC (macOS/Linux) | ✅ POSIX non-blocking UDP socket |
| ESP32 (Arduino) | ✅ WiFiUDP pool in pal::_detail |
| ESP-IDF (bare) | ⬜ Stubs — discovery inactive; no packets sent or received |
Setup example¶
{
"id": "discovery1",
"type": "DeviceDiscoveryModule",
"parent_id": "network1",
"inputs": { "network": "network1" }
}
Or via REST:
curl -X POST http://localhost:80/api/modules \
-H 'Content-Type: application/json' \
-d '{"id":"discovery1","type":"DeviceDiscoveryModule","parent_id":"network1","inputs":{"network":"network1"}}'
Test coverage¶
Unit tests live in tests/test_network.cpp (DeviceDiscovery section).
→ Network and WiFi — lifecycle, category, control registration, healthReport format, setInput wiring, broadcast_interval state round-trip, getControlValues.
Live: test0 — Infrastructure Modules — DeviceDiscoveryModule present (or created) as a child of NetworkModule on every device before each live test run.
Live: test4 — Device Discovery — waits up to 10 s for devices >= 1 in healthReport, confirming real UDP packets are exchanged between peers.
Implementation¶
src/modules/system/DeviceDiscovery.h- PAL UDP functions:
pal::udp_bind,pal::udp_broadcast,pal::udp_recv,pal::udp_close— seesrc/pal/Pal.h - Tests:
tests/test_network.cpp(DeviceDiscovery section)