|
FastLED 3.9.15
|
WLED-specific Remote RPC extension.
Extends the base Remote RPC system with WLED state management for controlling on/off state, brightness, segments, and effects.
Provides methods to:
WLED is a popular ESP8266/ESP32 firmware for controlling addressable LEDs over WiFi. It provides a comprehensive JSON API via HTTP endpoints like /json, /json/state, /json/info, /json/eff, /json/pal, etc.
FastLED does NOT implement a network server or HTTP endpoints. This reference documents WLED's JSON data structures and control properties that could be used for interoperability or implementing WLED-compatible control interfaces in FastLED-based projects
| Property | Range | Description |
|---|---|---|
| on | bool or "t" | Power toggle (true=on, false=off, "t"=toggle) |
| bri | 0-255 | Master brightness level |
| transition | 0-65535 | Crossfade duration (×100ms, e.g., 7 = 700ms) |
| ps | -1 to 250 | Active preset ID (-1=none) |
| pl | -1 to 250 | Active playlist ID (-1=none) |
| nl | object | Nightlight configuration (see below) |
| udpn | object | UDP sync settings |
| lor | 0-2 | Live data override (0=off, 1=override, 2=until reboot) |
| mainseg | 0-maxseg-1 | Main segment for global controls |
| seg | array | Segment configurations (see below) |
| playlist | object | Playlist configuration (see below) |
| Property | Range | Description |
|---|---|---|
| id | 0-maxseg-1 | Segment identifier (required for updates) |
| start | LED index | Starting LED position (inclusive) |
| stop | LED index | Ending LED position (exclusive) |
| len | count | Segment length (alternative to stop) |
| grp | count | LED grouping factor |
| spc | count | Spacing between groups |
| of | offset | Group offset |
| on | bool or "t" | Segment power state |
| bri | 0-255 | Segment brightness |
| cct | 0-255 or K | Color temperature (Kelvin 1900-10091 or 0-255) |
| col | array | Color slots [[R,G,B(,W)], ...] or ["RRGGBB", ...] |
| | - Index 0: Primary color | | - Index 1: Secondary color | | - Index 2: Tertiary color fx | 0-fxcount-1 | Effect ID sx | 0-255 | Effect speed ix | 0-255 | Effect intensity pal | 0-palcount-1 | Palette ID c1, c2, c3 | 0-255 | Effect custom parameters sel | bool | Segment selected for API control rev | bool | Reverse segment direction mi | bool | Mirror effect within segment o1, o2, o3 | bool | Effect option flags si | 0-3 | Sound simulation mode m12 | 0-3 | Segment mapping mode i | array | Individual LED control: ["RRGGBB", "RRGGBB", ...] | | - Use LED index or range: "i":["FF0000|10","00FF00|20-30"] n | string | Segment name rpt | bool | Repeat segment pattern
Colors: RGB(W) arrays [[R,G,B(,W)], ...] or hex strings ["RRGGBB", ...] Example: {"seg":[{"col":[[255,170,0],[0,0,0],[64,64,64]]}]} or {"seg":[{"col":["FFAA00","000000","404040"]}]}
Individual LEDs: {"seg":{"i":["FF0000","00FF00","0000FF"]}}
| Property | Description |
|---|---|
| ver | WLED version string |
| vid | Version ID (integer) |
| leds.count | Total LED count |
| leds.rgbw | True if 4-channel (RGBW) support |
| leds.wv | True if WLED version supports white channel |
| leds.cct | True if CCT control available |
| leds.pwr | Current power consumption (mW) |
| leds.maxpwr | Configured max power limit (mW) |
| leds.seglock | True if segments locked |
| str | Info string |
| name | Device name |
| udpport | UDP port number |
| live | True if in live/realtime mode |
| lm | Live mode data source |
| lip | Live data source IP |
| ws | WebSocket client count |
| fxcount | Number of available effects |
| palcount | Number of available palettes |
| cpalcount | Number of custom palettes |
| maps | LED mapping count |
| wifi.bssid | Connected AP BSSID |
| wifi.signal | WiFi signal strength (0-100) |
| wifi.channel | WiFi channel |
| fs.u | Used filesystem space (KB) |
| fs.t | Total filesystem space (KB) |
| fs.pmt | Last modification time |
| ndc | Node discovery count |
| arch | Architecture (esp8266/esp32/etc.) |
| core | Core/SDK version |
| lwip | LwIP version |
| freeheap | Free heap memory (bytes) |
| uptime | Uptime in seconds |
| opt | Build options/features bitfield |
| brand | Brand identifier |
| product | Product identifier |
| mac | MAC address |
| ip | IP address |
| Property | Range | Description |
|---|---|---|
| on | bool | Nightlight active |
| dur | 1-255 | Duration in minutes |
| mode | 0-3 | Transition mode: |
| | 0=Instant off, 1=Fade to off, 2=Color fade, | | 3=Sunrise (warmth increase) tbri | 0-255 | Target brightness for nightlight end rem | -1 to 255 | Remaining nightlight duration (read-only)
Example: {"nl":{"on":true,"dur":10,"mode":1}}
| Property | Description |
|---|---|
| ps | Array of preset IDs to cycle through |
| dur | Array of durations (seconds) for each preset |
| transition | Array of transition times (×100ms) for each preset |
| repeat | Number of cycles (0=infinite) |
| end | End preset ID (after playlist completes) |
| r | True for randomized playback order |
Example: {"playlist":{"ps":[26,20,18],"dur":[30,20,10],"repeat":10}}
Format: "<parameters>;<colors>;<palette>;<flags>;<defaults>"
This class currently implements basic WLED state management (on/bri). Future enhancements could include:
#include <wled.h>
Inheritance diagram for fl::WLED:
Collaboration diagram for fl::WLED:Public Member Functions | |
| WLED () FL_NOEXCEPT | |
| Construct WLED with default stub I/O callbacks. | |
| WLED (RequestSource source, ResponseSink sink) | |
| Construct WLED with custom I/O callbacks. | |
| const WLEDSegment * | findSegmentById (u8 id) const |
| Find segment by ID. | |
| u8 | getBrightness () const |
| Get WLED brightness. | |
| u8 | getLiveOverride () const |
| Get live data override setting. | |
| u8 | getMainSegment () const |
| Get main segment index. | |
| u8 | getNightlightDuration () const |
| Get nightlight duration. | |
| u8 | getNightlightMode () const |
| Get nightlight mode. | |
| bool | getNightlightOn () const |
| Get nightlight active state. | |
| u8 | getNightlightTargetBrightness () const |
| Get nightlight target brightness. | |
| bool | getOn () const |
| Get WLED on/off state. | |
| i16 | getPlaylist () const |
| Get active playlist ID. | |
| fl::json | getPlaylistConfig () const |
| Get playlist configuration. | |
| i16 | getPreset () const |
| Get active preset ID. | |
| const WLEDSegment & | getSegment (size_t index) const |
| Get segment by index. | |
| size_t | getSegmentCount () const |
| Get segment count. | |
| const fl::vector< WLEDSegment > & | getSegments () const |
| Get all segments. | |
| fl::json | getState () const |
| Get current WLED state as JSON object. | |
| u16 | getTransition () const |
| Get transition duration. | |
| bool | getUdpReceive () const |
| Get UDP sync receive setting. | |
| bool | getUdpSend () const |
| Get UDP sync send setting. | |
| bool | hasPlaylistConfig () const |
| Check if playlist is active. | |
| void | setState (const fl::json &wledState) |
| Set WLED state from JSON object. | |
Public Member Functions inherited from fl::Remote | |
| Remote (const Remote &) FL_NOEXCEPT=delete | |
| Remote (Remote &&) FL_NOEXCEPT=delete | |
| Remote (RequestSource source, ResponseSink sink) | |
| Construct with I/O callbacks. | |
| template<typename Callable> | |
| void | bind (const char *name, Callable fn, fl::RpcMode mode=fl::RpcMode::SYNC) |
| Register method by name, function, and optional mode (default SYNC) | |
| template<typename Callable> | |
| void | bind (const Config< Callable > &config) |
| Register method with config (name, function, optional metadata) | |
| void | bindAsync (const char *name, fl::function< void(fl::ResponseSend &, const fl::json &)> fn, fl::RpcMode mode=fl::RpcMode::ASYNC) |
| Register async method with ResponseSend& parameter (for ASYNC/ASYNC_STREAM modes) Signature: void(ResponseSend&, const json&) The ResponseSend& parameter provides send(), sendUpdate(), sendFinal() methods. | |
| void | clear (ClearFlags flags) |
| Clear state (bitwise OR of ClearFlags) | |
| fl::size | count () const |
| Get number of registered methods. | |
| template<class Sig> | |
| fl::BindResult< Sig > | get (const char *name) const |
| Get bound method by name for direct C++ invocation. | |
| bool | has (const fl::string &name) const |
| Check if method is registered. | |
| fl::vector< MethodInfo > | methods () const |
| Get method information for all registered methods. | |
| Remote & | operator= (const Remote &) FL_NOEXCEPT=delete |
| Remote & | operator= (Remote &&) FL_NOEXCEPT=delete |
| size_t | pendingCount () const |
| Get number of pending scheduled calls. | |
| fl::json | processRpc (const fl::json &request) |
| Process JSON-RPC request (with optional "timestamp" field for scheduling) Returns JSON-RPC response: {"result": ...} or {"error": {...}}. | |
| void | reportError (const fl::json &data) |
| Send an error notification with structured data Format: {"jsonrpc":"2.0","method":"__error","params":<data>}. | |
| void | reportError (const fl::string &message) |
| Send an error notification to the remote peer. | |
| fl::json | schema () const |
| Returns flat schema document Format: {"schema": [["methodName", "returnType", [["param1", "type1"], ...]], ...]}. | |
| void | sendAsyncResponse (const char *method, const fl::json &result) |
| Send async response for a previously-called async method The request ID is automatically retrieved from internal storage. | |
| void | sendStreamFinal (const char *method, const fl::json &result) |
| Send final stream response for a streaming async method (ASYNC_STREAM mode) The request ID is automatically retrieved from internal storage and method is removed. | |
| void | sendStreamUpdate (const char *method, const fl::json &update) |
| Send stream update for a streaming async method (ASYNC_STREAM mode) The request ID is automatically retrieved from internal storage. | |
| size_t | tick (u32 currentTimeMs) |
| Process scheduled calls (call regularly) | |
| bool | unbind (const fl::string &name) |
| Unregister method by name. | |
| size_t | update (u32 currentTimeMs) |
| Main update: pull + tick + push (overrides Server::update) | |
Public Member Functions inherited from fl::Server | |
| Server () FL_NOEXCEPT | |
| Default constructor. | |
| Server (const Server &) FL_NOEXCEPT=delete | |
| Server (RequestSource source, ResponseSink sink) | |
| Construct with I/O callbacks. | |
| Server (Server &&) FL_NOEXCEPT=default | |
| virtual | ~Server () FL_NOEXCEPT=default |
| Server & | operator= (const Server &) FL_NOEXCEPT=delete |
| Server & | operator= (Server &&) FL_NOEXCEPT=default |
| size_t | pull () |
| Pull requests from source, process, queue responses. | |
| size_t | push () |
| Push queued responses to sink. | |
| void | setRequestHandler (RequestHandler handler) |
| Set request handler. | |
| void | setRequestSource (RequestSource source) |
| Set request source callback. | |
| void | setResponseSink (ResponseSink sink) |
| Set response sink callback. | |
| size_t | update () |
| Main update: pull + push. | |
Private Member Functions | |
| fl::optional< fl::json > | stubRequestSource () |
| Stub request source callback. | |
| void | stubResponseSink (const fl::json &response) |
| Stub response sink callback. | |
Private Attributes | |
| u8 | mLiveOverride = 0 |
| u8 | mMainSegment = 0 |
| u8 | mNightlightDuration = 60 |
| u8 | mNightlightMode = 1 |
| bool | mNightlightOn = false |
| u8 | mNightlightTargetBrightness = 0 |
| i16 | mPlaylist = -1 |
| fl::vector< u16 > | mPlaylistDurations |
| i16 | mPlaylistEnd = -1 |
| fl::vector< i16 > | mPlaylistPresets |
| bool | mPlaylistRandomize = false |
| u16 | mPlaylistRepeat = 0 |
| fl::vector< u16 > | mPlaylistTransitions |
| i16 | mPreset = -1 |
| fl::vector< WLEDSegment > | mSegments |
| u16 | mTransition = 7 |
| bool | mUdpReceive = true |
| bool | mUdpSend = false |
| u8 | mWledBri = 255 |
| bool | mWledOn = false |
Additional Inherited Members | |
Public Types inherited from fl::Remote | |
| using | ClearFlags = fl::RemoteClearFlags |
| template<typename Callable> | |
| using | Config = typename fl::Rpc::Config<Callable> |
| Configuration for method registration (forwards to Rpc::Config) | |
| using | MethodInfo = fl::MethodInfo |
| using | ParamInfo = fl::ParamInfo |
| using | RpcResult = fl::RpcResult |
Public Types inherited from fl::Server | |
| using | RequestHandler = fl::function<fl::json(const fl::json&)> |
| using | RequestSource = fl::function<fl::optional<fl::json>()> |
| using | ResponseSink = fl::function<void(const fl::json&)> |
Protected Member Functions inherited from fl::Remote | |
| void | recordResult (const fl::string &funcName, const fl::json &result, u32 scheduledAt, u32 receivedAt, u32 executedAt, bool wasScheduled) |
| void | scheduleFunction (u32 timestamp, u32 receivedAt, const fl::json &jsonRpcRequest) |
Protected Attributes inherited from fl::Remote | |
| fl::unordered_map< fl::string, AsyncRequest > | mAsyncRequests |
| fl::vector< RpcResult > | mResults |
| fl::Rpc | mRpc |
| fl::net::RpcScheduler | mScheduler |
Protected Attributes inherited from fl::Server | |
| fl::vector< fl::json > | mOutgoingQueue |
| RequestHandler | mRequestHandler |
| RequestSource | mRequestSource |
| ResponseSink | mResponseSink |