FastLED 3.9.15
Loading...
Searching...
No Matches
RpcServer.ino File Reference

Detailed Description

Example demonstrating fl::Remote with HTTP streaming transport (server side)

This example shows how to:

  • Create an HTTP streaming RPC server on port 8080
  • Register SYNC, ASYNC, and ASYNC_STREAM methods
  • Handle incoming HTTP requests with chunked encoding
  • Send responses with ResponseSend API
  • Use heartbeat/keepalive for connection management

Test with curl or RpcClient.ino: SYNC mode (immediate response): curl -X POST http://localhost:8080/rpc \ -H "Content-Type: application/json" \ -H "Transfer-Encoding: chunked" \ -d '{"jsonrpc":"2.0","method":"add","params":[2,3],"id":1}'

ASYNC mode (ACK + later result): curl -X POST http://localhost:8080/rpc \ -H "Content-Type: application/json" \ -H "Transfer-Encoding: chunked" \ -d '{"jsonrpc":"2.0","method":"longTask","params":[1000],"id":2}'

ASYNC_STREAM mode (ACK + updates + final): curl -X POST http://localhost:8080/rpc \ -H "Content-Type: application/json" \ -H "Transfer-Encoding: chunked" \ -d '{"jsonrpc":"2.0","method":"streamData","params":[10],"id":3}'

See also
fl/remote/remote.h for full API documentation
fl/stl/asio/http/PROTOCOL.md for protocol specification

Definition in file RpcServer.ino.

+ Include dependency graph for RpcServer.ino:

Go to the source code of this file.

Macros

#define DATA_PIN   3
 
#define NUM_LEDS   10
 
#define SERVER_PORT   8080
 

Functions

void loop ()
 
void setup ()
 

Variables

CRGB leds [NUM_LEDS]
 
static fl::RemotepRemote = nullptr
 
static fl::shared_ptr< fl::net::http::HttpStreamServer > * pTransport = nullptr