FastLED
3.10.8
Loading...
Searching...
No Matches
serial.cpp.hpp
Go to the documentation of this file.
1
// src/fl/remote/transport/serial.cpp.hpp
2
// Implementation of JSON-RPC serial transport layer
3
4
#pragma once
5
6
#include "
fl/remote/transport/serial.h
"
7
#include "
fl/stl/cstring.h
"
8
#include "
fl/stl/strstream.h
"
9
#include "
fl/stl/noexcept.h
"
10
11
namespace
fl
{
12
13
fl::string
formatJsonResponse
(
const
fl::json
& response,
const
char
* prefix)
FL_NO_EXCEPT
{
14
// Use sstream to minimize allocations
15
fl::sstream
ss;
16
17
// Add prefix if provided
18
if
(prefix && prefix[0] !=
'\0'
) {
19
ss << prefix;
20
}
21
22
// Serialize to compact JSON
23
fl::string
jsonStr = response.to_string();
24
25
// Stream copy with inline filtering (replace newlines with spaces)
26
for
(
size_t
i = 0; i < jsonStr.
size
(); ++i) {
27
char
c = jsonStr[i];
28
ss << ((c ==
'\n'
|| c ==
'\r'
) ?
' '
: c);
29
}
30
31
return
ss.
str
();
32
}
33
34
}
// namespace fl
fl::basic_string::size
fl::size size() const FL_NO_EXCEPT
Definition
basic_string.h:153
fl::json
Definition
json.h:261
fl::sstream::str
string str() const FL_NO_EXCEPT
Definition
strstream.h:43
fl::sstream
Definition
strstream.h:34
fl::string
Definition
string.h:202
cstring.h
fl::FL_NO_EXCEPT
u8 u8 fract8 blur_amount FL_NO_EXCEPT
Definition
blur.h:186
fl::formatJsonResponse
fl::string formatJsonResponse(const fl::json &response, const char *prefix) FL_NO_EXCEPT
Serialize JSON response to a string.
Definition
serial.cpp.hpp:13
fl
Base definition for an LED controller.
Definition
crgb.hpp:179
noexcept.h
serial.h
strstream.h
fl
remote
transport
serial.cpp.hpp
Generated on Sun Oct 18 2026 00:56:52 for FastLED by
1.13.2