← All projects

Latest test build

Build 620 Oct 2026

Newest test build, not an official version.

VLight System Architecture & Technical Assessment

1. Executive Summary

VLight is a production-grade, distributed LED lighting cluster ecosystem designed around the V programming language (v0.5.2+), targeting Espressif microcontrollers (ESP32, ESP32-S2, ESP32-S3, ESP32-C3, ESP32-C6, ESP32-H2).

The system consists of:

  1. VLight Server (server/): A high-efficiency, native Linux daemon written in V for automatic node discovery, zero-touch secure provisioning, device registry, group/scene coordination, and client APIs (REST + WebSockets).
  2. VLight Embedded SDK (sdk/): A clean, memory-conscious V framework for ESP32 firmware development that abstracts hardware registers, FreeRTOS tasks, Wi-Fi, NVS, and high-performance WS2812B LED timing.
  3. VLight Toolchain & CLI (tools/vlight-cli): A firmware development pipeline that transpiles V to freestanding C99, injects embedded compatibility shims and FreeRTOS app_main entry points, and produces valid firmware images via PlatformIO Core or ESP-IDF.
  4. VLight Node Firmware (firmware/): Autonomous lighting firmware executing color mixing, gamma correction, and real-time effects locally on the microcontroller.
  5. VLight Android Application (android/): A modern Kotlin + Jetpack Compose mobile client for discovery, real-time color picking, group management, and scene execution.

2. Technical Assessment of Existing ESPSmartHome Reference

We performed a deep-dive inspection and verification of the existing reference repository (ESPSmartHome):

2.1 Reusable Components & Proven Assets

  • V-to-C Transpilation Pipeline: Successfully verified v -gc none -no-bounds-checking -d no_main -d no_backtrace producing freestanding C source without desktop runtime dependencies.
  • Embedded Compatibility Shims: Proven headers and C stubs (sys/mman.h, mach-o/dyld.h, gc.h, execinfo.h) that satisfy V's emitted runtime references without requiring full POSIX or Boehm GC.
  • ESP-IDF / FreeRTOS Entry Point: Proven generation of app_main(void) bridge calling _vinit() followed by main__main().
  • Target Matrix & Pin Safety Validation: Rich database of ESP32 chip architectures, strapping pins (GPIO 0, 2, 5, 12, 15), input-only pins (GPIO 34-39), and RMT peripheral availability.
  • Espressif Firmware Image Generator: Working 24-byte header generator injecting magic 0xE9, chip identification numbers, segment counts, and entry points into flashable .bin images.
  • Cryptographic Physical-Presence Pairing: Debounced physical BOOT-button state machine (3-second press) paired with HMAC-SHA256 mutual challenge-response token enrollment.
  • Database Architecture: SQLite WAL mode engine with structured schemas for devices, credentials, and settings.

2.2 Identified Gaps & Missing Functionality for Lighting Clusters

  • LED Subsystem Limitations: The reference vhome LED module provided only minimal memory arrays without hardware RMT timing, gamma correction tables, RGBW support, power limiter calculations, or multi-frame effect engines.
  • Effect Calculation Model: No local multi-frame animation engine (rainbow, pulse, breathing, chase, wave, twinkle). Lighting commands must run autonomous effects on the node rather than streaming individual frame packets over the network.
  • Network Synchronization: Lack of distributed cluster synchronization or group-level synchronized effect execution across multiple nodes.
  • Zero-Touch Local Discovery: Needs UDP broadcast/multicast and mDNS beaconing specifically advertising VLight controller capabilities and port bindings.
  • Mobile Client: The reference repository included a Vue 3 web frontend; VLight requires a dedicated native Android application built with Kotlin and Jetpack Compose.

3. Detailed Subsystem Architecture

                                 ┌───────────────────────────────────┐
                                 │     VLight Android Client         │
                                 │   - Jetpack Compose M3 UI         │
                                 │   - UDP Broadcast Auto-Discovery  │
                                 │   - Dual Mode: REST & WebSockets  │
                                 │   - Color Wheels & Scene Triggers │
                                 └─────────────────▲─────────────────┘
                                                   │ HTTP / WS (:8443 or :8080)
                                                   ▼
┌────────────────────────────────────────────────────────────────────────────────────┐
│                              VLight Linux Server (V Core)                          │
│                                                                                    │
│   ┌─────────────────────┐   ┌─────────────────────┐   ┌────────────────────────┐   │
│   │   Discovery Engine  │   │  Provisioning & Sec │   │  Cluster Orchestrator  │   │
│   │  - UDP Broadcast/MC │   │  - HMAC-SHA256 Auth │   │  - Groups & Scenes     │   │
│   │  - Node Heartbeats  │   │  - Token Store (DB) │   │  - Effect Sync Engine  │   │
│   └─────────────────────┘   └─────────────────────┘   └────────────────────────┘   │
│                                                                                    │
│   ┌───────────────────────────────────────────────┐   ┌────────────────────────┐   │
│   │            VEB HTTP & WebSocket API           │   │    SQLite Persistence  │   │
│   │  - /api/v1/nodes, /api/v1/groups, /api/scenes │   │  - Nodes, Keys, Scenes │   │
│   └───────────────────────────────────────────────┘   └────────────────────────┘   │
└──────────────────────────────────────────▲─────────────────────────────────────────┘
                                           │ Authenticated WS / JSON-RPC
                                           ▼
┌────────────────────────────────────────────────────────────────────────────────────┐
│                           VLight ESP32 Lighting Nodes                              │
│                                                                                    │
│   ┌────────────────────────────────────────────────────────────────────────────┐   │
│   │                          Application Code (V)                              │   │
│   │   vlight.Device, vlight.led.WS2812B, vlight.effects.Engine                │   │
│   └─────────────────────────────────────┬──────────────────────────────────────┘   │
│                                         │                                          │
│   ┌─────────────────────────────────────▼──────────────────────────────────────┐   │
│   │                           VLight Embedded SDK                              │   │
│   │   - Network discovery client & secure NVS token storage                    │   │
│   │   - Local Effect Engine (Solid, Pulse, Rainbow, Breathing, Chase, Comet)   │   │
│   │   - RMT Peripheral Driver / FreeRTOS Task Bridge                           │   │
│   └─────────────────────────────────────┬──────────────────────────────────────┘   │
│                                         │                                          │
│   ┌─────────────────────────────────────▼──────────────────────────────────────┐   │
│   │                         Microcontroller Peripherals                        │   │
│   │   - BOOT Button (GPIO0/9)       - Status LED       - WS2812B Strip (RMT)   │   │
│   └────────────────────────────────────────────────────────────────────────────┘   │
└────────────────────────────────────────────────────────────────────────────────────┘

4. End-to-End Lighting Protocol

  1. Discovery (Zero-Touch UDP):
    • Server periodically broadcasts VLIGHT_SERVER_ANNOUNCE packet on UDP port 9123 containing { "proto": "vlight", "version": 1, "server_id": "...", "port": 8080 }.
    • Node on boot listens for server broadcasts or transmits VLIGHT_NODE_BEACON on UDP port 9123.
  2. Secure Provisioning Session:
    • Physical presence is verified via BOOT button press (3 seconds).
    • Node issues POST /api/v1/provision/request with device info and nonce.
    • Server issues challenge nonce; node returns HMAC-SHA256 signature.
    • Server returns durable auth token which node saves in NVS flash.
  3. Persistent WebSocket Command Link:
    • Authenticated WebSocket connects to /api/v1/ws/node.
    • Heartbeat exchange (ping / pong) every 15 seconds.
    • Lighting commands specify color, brightness, effect, speed, and optional synchronization timestamps.