55template<
typename SerialIn>
62template<
typename SerialOut>
122 if (!line.has_value() || line->empty()) {
130 if (prefix && prefix[0] !=
'\0') {
147 if (view.
empty() || view[0] !=
'{') {
163 return [prefix](
const fl::json& response) {
190template<
typename SerialIn>
196template<
typename SerialIn>
214 int c = serial.read();
225 if (c == delimiter) {
235 buffer << static_cast<char>(c);
244template<
typename SerialOut>
246 serial.println(str.
c_str());
FastLED chrono implementation - duration types for time measurements.
bool has_value() const FL_NOEXCEPT
const char * c_str() const FL_NOEXCEPT
static json parse(const fl::string &txt) FL_NOEXCEPT
string str() const FL_NOEXCEPT
constexpr bool empty() const FL_NOEXCEPT
void remove_suffix(fl::size n) FL_NOEXCEPT
constexpr const char & front() const FL_NOEXCEPT
bool starts_with(string_view sv) const FL_NOEXCEPT
constexpr const char & back() const FL_NOEXCEPT
void remove_prefix(fl::size n) FL_NOEXCEPT
Delay utilities for FastLED Includes nanosecond-precision delays, cycle counting, and microsecond del...
FastLED's Elegant JSON Library: fl::json
fl::optional< fl::string > readSerialStringUntil(SerialIn &serial, char delimiter, char skipChar, fl::optional< u32 > timeoutMs)
size_t strlen(const char *s) FL_NOEXCEPT
fl::u32 millis()
Universal millisecond timer - returns milliseconds since system startup.
fl::string formatJsonResponse(const fl::json &response, const char *prefix)
Serialize JSON response to a string.
fl::optional< fl::string > readSerialLine(SerialIn &serial, char delimiter='\n', fl::optional< u32 > timeoutMs=fl::nullopt)
Read a line from a serial-like input source (blocking with optional timeout)
fl::function< fl::optional< fl::json >()> createSerialRequestSource(const char *prefix="")
Create a JSON-RPC RequestSource that reads from fl:: serial input.
fl::pair< fl::function< fl::optional< fl::json >()>, fl::function< void(const fl::json &)> > createSerialTransport(const char *responsePrefix="REMOTE: ", const char *requestPrefix="")
Create RequestSource and ResponseSink pair for serial I/O.
void writeSerialLine(SerialOut &serial, const fl::string &str)
Write a string with newline to a serial-like output.
expected< T, E > result
Alias for expected (Rust-style naming)
constexpr nullopt_t nullopt
fl::function< void(const fl::json &)> createSerialResponseSink(const char *prefix="REMOTE: ")
Create a JSON-RPC ResponseSink that writes to fl:: serial output.
void println(const char *str) FL_NOEXCEPT
void delayMicroseconds(u32 us)
Delay for a given number of microseconds.
bool isspace(char c) FL_NOEXCEPT
Check if character is whitespace (space, tab, newline, carriage return)
fl::optional< fl::string > readLine(char delimiter, char skipChar, fl::optional< u32 > timeoutMs)
Base definition for an LED controller.
Serial adapter using fl:: input functions (fl::available, fl::read)
void println(const char *str)
Serial adapter using fl:: output functions (fl::println)