21#undef FASTLED_STUB_MAIN_FAST_EXIT
30#include "platforms/stub_main.hpp"
35#define SERVER_PORT 8081
75 FL_WARN(
"\n=== Test 1: GET /json (Slideshow Data) ===");
81 FL_WARN(
"✗ FAILED: " << result.error_message());
88 if (resp.
status() != 200) {
96 FL_WARN(
"✗ FAILED: Response is not JSON");
105 int slide_count = data[
"slideshow"][
"slides"].
size();
107 if (author ==
"unknown" ||
title ==
"untitled" || slide_count == 0) {
108 FL_WARN(
"✗ FAILED: Invalid JSON structure");
109 FL_WARN(
" Author: " << author);
111 FL_WARN(
" Slides: " << slide_count);
118 FL_WARN(
" Author: " << author);
120 FL_WARN(
" Slides: " << slide_count);
125 FL_WARN(
"\n=== Test 2: GET /get (Request Echo) ===");
131 FL_WARN(
"✗ FAILED: " << result.error_message());
138 if (resp.
status() != 200) {
146 FL_WARN(
"✗ FAILED: Response is not JSON");
156 if (origin ==
"unknown" || url ==
"unknown") {
157 FL_WARN(
"✗ FAILED: Invalid response structure");
164 FL_WARN(
" Origin: " << origin);
170 FL_WARN(
"\n=== Test 3: GET /ping (Health Check) ===");
176 FL_WARN(
"✗ FAILED: " << result.error_message());
183 if (resp.
status() != 200) {
191 if (body !=
"pong\n") {
192 FL_WARN(
"✗ FAILED: Expected 'pong\\n', got '" << body <<
"'");
205 Serial.println(
"\nHTTP Client Validation Suite (Loopback Mode)");
206 Serial.println(
"Starting self-contained server + client test\n");
216 const char* json_response = R
"({
218 "author": "FastLED Community",
219 "title": "FastLED Tutorial",
221 {"title": "Introduction to FastLED", "type": "tutorial"},
222 {"title": "LED Basics", "type": "lesson"},
223 {"title": "HTTP Fetch API", "type": "demo"}
229 .header("Content-Type",
"application/json")
230 .body(json_response);
236 const char* json_response = R
"({
237 "origin": "127.0.0.1",
238 "url": "http://localhost:8081/get"
242 .header("Content-Type",
"application/json")
243 .body(json_response);
254 Serial.print(
"Server started on http://localhost:");
258 Serial.println(
"ERROR: Failed to start server");
275 FL_WARN(
"=================================");
276 FL_WARN(
"Starting HTTP Client Tests");
277 FL_WARN(
"=================================");
298 FL_WARN(
"\n=================================");
300 FL_WARN(
"=================================");
304 FL_WARN(
"=================================");
310 FL_WARN(
"\n=================================");
312 FL_WARN(
"=================================");
316 FL_WARN(
"=================================");
317 FL_WARN(
"✗ Some tests FAILED");
321 fl::stub_main::stop_loop();
328 fl::stub_main::stop_loop();
fl::UITitle title("Animartrix")
void test_ping_endpoint()
void test_json_endpoint()
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
static Response ok(const string &body="")
Factory method for 200 OK response.
fl::size length() const FL_NOEXCEPT
size_t size() const FL_NOEXCEPT
const fl::string & text() const
Response body as text (like JavaScript response.text())
bool is_json() const
Check if response appears to contain JSON content.
const fl::string & status_text() const
HTTP status text (like JavaScript response.statusText)
int status() const
HTTP status code (like JavaScript response.status)
fl::json json() const
Response body parsed as JSON (JavaScript-like API)
HTTP response class (unified interface)
string substr(fl::size start, fl::size length) const FL_NOEXCEPT
Promise class that provides fluent .then() and .catch_() semantics This is a lightweight wrapper arou...
Result type for promise operations.
void fill_solid(CRGB *targetArray, int numToFill, const CRGB &color) FL_NOEXCEPT
Fill a range of LEDs with a solid color.
Task executor — runs registered task runners and manages the run loop.
Unified HTTP fetch API for FastLED (cross-platform)
LIB8STATIC u8 beatsin8(accum88 beats_per_minute, u8 lowest=0, u8 highest=255, u32 timebase=0, u8 phase_offset=0) FL_NOEXCEPT
Generates an 8-bit sine wave at a given BPM that oscillates within a given range.
fl::task::Promise< Response > fetch_get(const fl::string &url, const FetchOptions &request)
HTTP GET request.
PromiseResult< T > await_top_level(Promise< T > p)
Synchronously wait for a promise to complete (ONLY safe in top-level contexts)
asio::http::Request http_request
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
asio::http::Response http_response
asio::http::Server HttpServer
Representation of an 8-bit RGB pixel (Red, Green, Blue)