FastLED 3.9.15
Loading...
Searching...
No Matches

◆ handleClientResponse()

void handleClientResponse ( const fl::json & response)

Definition at line 336 of file RpcBidirectional.ino.

336 {
337 if (response.contains("result")) {
338 const fl::json& result = response["result"];
339
340 // ACK
341 if (result.contains("ack")) {
342 auto ackOpt = result["ack"].as_bool();
343 if (ackOpt && *ackOpt) {
344 Serial.println("<<< [CLIENT] Received ACK");
345 return;
346 }
347 }
348
349 // Update
350 if (result.contains("update")) {
351 auto updateOpt = result["update"].as_int();
352 if (updateOpt) {
353 int update = *updateOpt;
354 fl::printf("<<< [CLIENT] Received update: %d\n", update);
355 leds[update % NUM_LEDS] = CRGB::Purple;
356 FastLED.show();
357 }
358 return;
359 }
360
361 // Final
362 if (result.contains("stop")) {
363 auto stopOpt = result["stop"].as_bool();
364 if (stopOpt && *stopOpt) {
365 Serial.println("<<< [CLIENT] Received FINAL result");
366 waitingForResponse = false;
367 return;
368 }
369 }
370
371 // Regular result
372 Serial.print("<<< [CLIENT] Received result: ");
373 Serial.println(result.to_string().c_str());
374 waitingForResponse = false;
375 }
376}
#define NUM_LEDS
fl::CRGB leds[NUM_LEDS]
FL_DISABLE_WARNING_PUSH FL_DISABLE_WARNING_GLOBAL_CONSTRUCTORS CFastLED FastLED
Global LED strip management instance.
bool waitingForResponse
void printf(const char *format, const Args &... args) FL_NOEXCEPT
Printf-like formatting function that prints directly to the platform output.
Definition stdio.h:635
expected< T, E > result
Alias for expected (Rust-style naming)
Definition result.h:31
@ Purple
<div style='background:#800080;width:4em;height:4em;'></div>
Definition crgb.h:621
#define Serial
Definition serial.h:304

References FastLED, leds, NUM_LEDS, fl::printf(), fl::CRGB::Purple, Serial, and waitingForResponse.

Referenced by loop().

+ Here is the call graph for this function:
+ Here is the caller graph for this function: