[SYS] Log Theengs props deserilization failures (#1907)
* Log Theengs props deserilization failures Now we log failing theengs json props deserialization failures. Note: the rest of the function implementation is kept as is, with no null/data-validity checks, and it is likely to encounter a crash later in the strcmp conditionals like in #1905. Related to #1905 Signed-off-by: Sami Salonen <ssalonen@gmail.com> * formatting fix for logging Signed-off-by: Sami Salonen <ssalonen@gmail.com> --------- Signed-off-by: Sami Salonen <ssalonen@gmail.com>
This commit is contained in:
1 parent
5432016c29
commit
e55431ad94
1 file changed
+12
-1
+12
-1
@@ -1020,7 +1020,18 @@ void launchBTDiscovery(bool overrideDiscovery) {
|
||||
}
|
||||
if (!properties.empty()) {
|
||||
StaticJsonDocument<JSON_MSG_BUFFER> jsonBuffer;
|
||||
deserializeJson(jsonBuffer, properties);
|
||||
auto error = deserializeJson(jsonBuffer, properties);
|
||||
if (error) {
|
||||
if (jsonBuffer.overflowed()) {
|
||||
// This should not happen if JSON_MSG_BUFFER is large enough for
|
||||
// the Theengs json properties
|
||||
Log.error(F("JSON deserialization of Theengs properties overflowed (error %s), buffer capacity: %u. Program might crash. Properties json: %s" CR),
|
||||
error.c_str(), jsonBuffer.capacity(), properties.c_str());
|
||||
} else {
|
||||
Log.error(F("JSON deserialization of Theengs properties errored: %" CR),
|
||||
error.c_str());
|
||||
}
|
||||
}
|
||||
for (JsonPair prop : jsonBuffer["properties"].as<JsonObject>()) {
|
||||
Log.trace(F("Key: %s"), prop.key().c_str());
|
||||
Log.trace(F("Unit: %s"), prop.value()["unit"].as<const char*>());
|
||||
|
||||
Reference in new issue
Block a user