global cleaning, restructure

This commit is contained in:
Yuri Trikoz
2020-06-20 14:27:58 +03:00
parent ece010976e
commit 6f310e5e07
81 changed files with 11067 additions and 1587 deletions

42
src/Utils/JsonUtils.cpp Normal file
View File

@@ -0,0 +1,42 @@
#include "Utils\JsonUtils.h"
#include <ArduinoJson.h>
String jsonReadStr(String& json, String name) {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(json);
return root[name].as<String>();
}
int jsonReadInt(String& json, String name) {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(json);
return root[name];
}
String jsonWriteStr(String& json, String name, String volume) {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(json);
root[name] = volume;
json = "";
root.printTo(json);
return json;
}
String jsonWriteInt(String& json, String name, int volume) {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(json);
root[name] = volume;
json = "";
root.printTo(json);
return json;
}
String jsonWriteFloat(String& json, String name, float volume) {
DynamicJsonBuffer jsonBuffer;
JsonObject& root = jsonBuffer.parseObject(json);
root[name] = volume;
json = "";
root.printTo(json);
return json;
}