diff --git a/src/Sys/SysModModel.h b/src/Sys/SysModModel.h index 6ec3eee1..38d39185 100644 --- a/src/Sys/SysModModel.h +++ b/src/Sys/SysModModel.h @@ -86,15 +86,17 @@ namespace ArduinoJson { dst["x"] = src.x; dst["y"] = src.y; dst["z"] = src.z; - USER_PRINTF("Coord3D toJson %d,%d,%d -> {x:%d,y:%d,z:%d}\n", src.x, src.y, src.z, dst["x"].as(), dst["y"].as(), dst["z"].as()); + USER_PRINTF("Coord3D toJson %d,%d,%d -> %s\n", src.x, src.y, src.z, dst.as().c_str()); return true; } static Coord3D fromJson(JsonVariantConst src) { + USER_PRINTF("Coord3D fromJson %s\n", src.as().c_str()); return Coord3D{src["x"], src["y"], src["z"]}; } static bool checkJson(JsonVariantConst src) { + USER_PRINTF("Coord3D checkJson %s\n", src.as().c_str()); return src["x"].is() && src["y"].is() && src["z"].is(); } }; @@ -174,7 +176,7 @@ class SysModModel:public SysModule { } else { USER_PRINTF("setValue changed %s %s -> %s\n", jsonToChar(var, "id"), oldValue.c_str(), var["value"].as().c_str()); //old value - web->addResponse(var["id"], "value", var["value"], rowNr); + web->addResponse(var["id"], "value", var["value"]); changed = true; } } @@ -197,12 +199,11 @@ class SysModModel:public SysModule { notSame = valueArray[rowNr].isNull() || valueArray[rowNr].as() != value; if (notSame) { - // setValue(var, value, rowNr); // if (rowNr >= valueArray.size()) // USER_PRINTF("notSame %d %d\n", rowNr, valueArray.size()); valueArray[rowNr] = value; //if valueArray[().c_str()); - web->addResponse(var["id"], "value", var["value"], rowNr); + web->addResponse(var["id"], "value", var["value"]); //send the whole array to UI as response is in format value: !! changed = true; } } diff --git a/src/Sys/SysModUI.cpp b/src/Sys/SysModUI.cpp index c9cf9c6f..0c0ad217 100644 --- a/src/Sys/SysModUI.cpp +++ b/src/Sys/SysModUI.cpp @@ -238,8 +238,10 @@ void SysModUI::processJson(JsonVariant json) { else { if (newValue.is()) mdl->setValue(var, JsonString(newValue, JsonString::Copied), rowNr); + else if (newValue.is()) //otherwise it will be treated as JsonObject and toJson / fromJson will not be triggered!!! + mdl->setValue(var, newValue.as(), rowNr); else - mdl->setValue(var, newValue.as(), rowNr); + mdl->setValue(var, newValue, rowNr); } // json.remove(key); //key / var["id"] processed we don't need the key in the response }