make a copy of cmd, ArudinoJson alters original one
This commit is contained in:
parent
d232bc4ffa
commit
389242f493
@ -122,7 +122,8 @@ void runRcSwitchCommand(JsonVariant jsonDoc) {
|
|||||||
// blink();
|
// blink();
|
||||||
}
|
}
|
||||||
|
|
||||||
void runJsonCommands(String cmd) {
|
void runJsonCommands(const char* cmd) {
|
||||||
|
String origCmd = String(cmd);
|
||||||
StaticJsonDocument<512> jsonArray;
|
StaticJsonDocument<512> jsonArray;
|
||||||
DeserializationError err = deserializeJson(jsonArray, cmd);
|
DeserializationError err = deserializeJson(jsonArray, cmd);
|
||||||
if (err == DeserializationError::Ok) {
|
if (err == DeserializationError::Ok) {
|
||||||
@ -133,7 +134,9 @@ void runJsonCommands(String cmd) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
Serial.println(String(err.c_str()) + ": " + cmd);
|
Serial.print(err.c_str());
|
||||||
|
Serial.print(": ");
|
||||||
|
Serial.println(origCmd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -150,6 +153,6 @@ void readCommand() {
|
|||||||
cmd = cmd.substring(0, cmd.lastIndexOf(','));
|
cmd = cmd.substring(0, cmd.lastIndexOf(','));
|
||||||
}
|
}
|
||||||
cmd = "[" + cmd + "]";
|
cmd = "[" + cmd + "]";
|
||||||
runJsonCommands(cmd);
|
runJsonCommands(cmd.c_str());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user