|
FastLED 3.9.15
|
Example demonstrating fl::Remote with HTTP streaming transport (server side)
This example shows how to:
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}'
Definition in file RpcServer.ino.
#include <FastLED.h>#include "fl/remote/remote.h"#include "fl/remote/rpc/response_send.h"#include "fl/net/http/stream_server.h"#include "fl/net/http/stream_server.cpp.hpp"#include "fl/net/http/stream_transport.cpp.hpp"#include "fl/stl/asio/http/connection.cpp.hpp"#include "fl/net/http/chunked_encoding.cpp.hpp"#include "fl/stl/asio/http/http_parser.cpp.hpp"#include "fl/stl/asio/http/native_server.cpp.hpp"
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::Remote * | pRemote = nullptr |
| static fl::shared_ptr< fl::net::http::HttpStreamServer > * | pTransport = nullptr |