more json optimization:
- reduce allocated size using correct const/not const char* - double buffer size for input serial
This commit is contained in:
parent
c61880db57
commit
ed755abb14
@ -11,7 +11,7 @@
|
||||
|
||||
|
||||
RCSwitch mySwitch = RCSwitch();
|
||||
SerialReader<100> serialReader;
|
||||
SerialReader<200> serialReader;
|
||||
|
||||
void setup() {
|
||||
digitalWrite(RESET_PIN, HIGH);
|
||||
@ -63,7 +63,7 @@ void readRcSwitch() {
|
||||
}
|
||||
|
||||
void handleJsonError(DeserializationError err, const char* cmd) {
|
||||
StaticJsonDocument<150> jsonError;
|
||||
StaticJsonDocument<50> jsonError;
|
||||
JsonObject error = jsonError.createNestedObject("error");
|
||||
error["msg"] = err.c_str();
|
||||
error["orig_cmd"] = cmd;
|
||||
@ -71,8 +71,8 @@ void handleJsonError(DeserializationError err, const char* cmd) {
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
void runJsonCommand(const char* cmd) {
|
||||
StaticJsonDocument<100> jsonDoc;
|
||||
void runJsonCommand(char* cmd) {
|
||||
StaticJsonDocument<50> jsonDoc;
|
||||
DeserializationError err = deserializeJson(jsonDoc, cmd);
|
||||
if (err == DeserializationError::Ok) {
|
||||
if (jsonDoc.containsKey("rcSwitch")) {
|
||||
@ -90,7 +90,7 @@ void runJsonCommand(const char* cmd) {
|
||||
|
||||
void readCommand() {
|
||||
if (serialReader.readLine(Serial) > 0) {
|
||||
const char* cmd = serialReader.getBuffer();
|
||||
char* cmd = serialReader.getBuffer();
|
||||
if (strcmp("reset", cmd) == 0) {
|
||||
Serial.println("resetting...");
|
||||
delay(200);
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user