VLight Network Protocol Specification (v1.0)
1. Overview
The VLight protocol coordinates distributed ESP32 lighting nodes with a central VLight Linux server and mobile applications. It operates in two layers:
- Discovery Layer (UDP Broadcast / Multicast on port 9123)
- Control & Telemetry Layer (Authenticated WebSockets / REST on port 8080/8443)
All payloads are formatted as strictly validated JSON objects.
2. Discovery Protocol
2.1 Server Announcement (Beacon)
The server broadcasts on UDP port 9123 every 5 seconds:
{
"proto": "vlight",
"version": 1,
"type": "server_announce",
"server_id": "vlight_srv_4a2c1f",
"server_name": "VLight Cluster Hub",
"http_port": 8080,
"ws_port": 8080,
"timestamp": 1729431800
}
2.2 Node Discovery Beacon
An unprovisioned or reconnecting node broadcasts on UDP port 9123:
{
"proto": "vlight",
"version": 1,
"type": "node_beacon",
"node_id": "esp32_30aea4010203",
"mac": "30:AE:A4:01:02:03",
"chip": "esp32s3",
"fw_version": "1.0.0",
"ip": "192.168.1.142",
"is_provisioned": false,
"boot_button_pressed": true
}
2.3 Client Active Discovery Probe
Mobile applications or CLI tools searching for active cluster hubs broadcast an active query on UDP port 9123:
{
"proto": "vlight",
"type": "discover"
}
The server immediately replies directly to the client's source IP and port with the standard server_announce payload.
2.4 Direct IP Fallback Connection
If UDP broadcast traffic is suppressed by router AP isolation, multi-band Wi-Fi separation (e.g. 2.4GHz vs 5GHz), or OS-level application firewalls (e.g. macOS Application Firewall), mobile clients fall back to direct HTTP connection via GET /api/v1/status on port 8080 (e.g. http://192.168.1.150:8080).
3. Secure Provisioning Flow
- Window Initiation: Admin opens the 120-second pairing window via Server CLI (
vlight-server pair open) or Android App (POST /api/v1/pairing/open). - Challenge Request: Node sends:
POST /api/v1/pairing/request { "node_id": "esp32_30aea4010203", "device_nonce": "9b1e8f3a7c6d4e2b", "chip": "esp32s3", "model": "vlight-strip-v1" } - Challenge Issue: Server responds with
hub_nonce:{ "status": "challenge", "hub_nonce": "3c8f2a1d9e4b7f0e", "session_id": "sess_81023b" } - Mutual Proof Handshake:
- Node computes
HMAC_SHA256(DEV_KEY, hub_nonce || device_nonce). - Node sends proof:
POST /api/v1/pairing/enroll { "session_id": "sess_81023b", "node_id": "esp32_30aea4010203", "proof": "a8fbc7102e...64_hex_chars..." }
- Node computes
- Durable Token Grant:
- Server verifies proof, registers node, and returns durable auth token:
{ "status": "enrolled", "token": "vlt_sec_891f0a2e4b6c8d1e", "node_id": "esp32_30aea4010203", "server_pubkey": "..." } - Node stores
vlt_sec_*in ESP32 Non-Volatile Storage (NVS).
- Server verifies proof, registers node, and returns durable auth token:
4. WebSocket Command & Telemetry Protocol
Connected nodes establish a persistent WebSocket connection to /api/v1/ws/node with header Authorization: Bearer <token>.
4.1 Server to Node: Set Lighting State (lighting.set)
{
"version": 1,
"type": "lighting.set",
"request_id": "req_a1b2c3d4",
"payload": {
"power": true,
"brightness": 200,
"color": { "r": 255, "g": 120, "b": 30 },
"effect": "breathe",
"speed": 12,
"sync_time_ms": 1729432000500
}
}
4.2 Node to Server: Command Acknowledgment (lighting.ack)
{
"version": 1,
"type": "lighting.ack",
"request_id": "req_a1b2c3d4",
"node_id": "esp32_30aea4010203",
"status": "ok",
"current_power": true,
"current_brightness": 200,
"current_effect": "breathe"
}
4.3 Heartbeat Exchange
- Ping (Node -> Server):
{"type": "ping", "uptime_s": 1420, "heap_free": 184320} - Pong (Server -> Node):
{"type": "pong", "server_time_ms": 1729432001000}