mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 11:59:12 +03:00
test completed - working
This commit is contained in:
@@ -15,10 +15,10 @@ bool jsonRead(String& json, String key, String& value);
|
|||||||
bool jsonRead(String& json, String key, bool& value);
|
bool jsonRead(String& json, String key, bool& value);
|
||||||
bool jsonRead(String& json, String key, int& value);
|
bool jsonRead(String& json, String key, int& value);
|
||||||
|
|
||||||
bool jsonWrite(String& json, String name, String value);
|
bool jsonWriteStr_(String& json, String name, String value);
|
||||||
bool jsonWrite(String& json, String name, bool value);
|
bool jsonWriteBool_(String& json, String name, bool value);
|
||||||
bool jsonWrite(String& json, String name, int value);
|
bool jsonWriteInt_(String& json, String name, int value);
|
||||||
bool jsonWrite(String& json, String name, float value);
|
bool jsonWriteFloat_(String& json, String name, float value);
|
||||||
|
|
||||||
void saveConfig();
|
void saveConfig();
|
||||||
void saveStore();
|
void saveStore();
|
||||||
@@ -114,7 +114,7 @@ String jsonWriteFloat(String& json, String name, float value) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
//new==============================================================================
|
//new==============================================================================
|
||||||
bool jsonWrite(String& json, String name, String value) {
|
bool jsonWriteStr_(String& json, String key, String value) {
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
DeserializationError error = deserializeJson(doc, json);
|
DeserializationError error = deserializeJson(doc, json);
|
||||||
@@ -122,13 +122,13 @@ bool jsonWrite(String& json, String name, String value) {
|
|||||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
doc[name] = value;
|
doc[key] = value;
|
||||||
json = "";
|
json = "";
|
||||||
serializeJson(doc, json);
|
serializeJson(doc, json);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool jsonWrite(String& json, String name, bool value) {
|
bool jsonWriteBool_(String& json, String key, bool value) {
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
DeserializationError error = deserializeJson(doc, json);
|
DeserializationError error = deserializeJson(doc, json);
|
||||||
@@ -136,13 +136,13 @@ bool jsonWrite(String& json, String name, bool value) {
|
|||||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
doc[name] = value;
|
doc[key] = value;
|
||||||
json = "";
|
json = "";
|
||||||
serializeJson(doc, json);
|
serializeJson(doc, json);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool jsonWrite(String& json, String name, int value) {
|
bool jsonWriteInt_(String& json, String key, int value) {
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
DeserializationError error = deserializeJson(doc, json);
|
DeserializationError error = deserializeJson(doc, json);
|
||||||
@@ -150,13 +150,13 @@ bool jsonWrite(String& json, String name, int value) {
|
|||||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
doc[name] = value;
|
doc[key] = value;
|
||||||
json = "";
|
json = "";
|
||||||
serializeJson(doc, json);
|
serializeJson(doc, json);
|
||||||
return ret;
|
return ret;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool jsonWrite(String& json, String name, float value) {
|
bool jsonWriteFloat_(String& json, String key, float value) {
|
||||||
bool ret = true;
|
bool ret = true;
|
||||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||||
DeserializationError error = deserializeJson(doc, json);
|
DeserializationError error = deserializeJson(doc, json);
|
||||||
@@ -164,7 +164,7 @@ bool jsonWrite(String& json, String name, float value) {
|
|||||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||||
ret = false;
|
ret = false;
|
||||||
}
|
}
|
||||||
doc[name] = value;
|
doc[key] = value;
|
||||||
json = "";
|
json = "";
|
||||||
serializeJson(doc, json);
|
serializeJson(doc, json);
|
||||||
return ret;
|
return ret;
|
||||||
|
|||||||
@@ -92,7 +92,7 @@ void setup() {
|
|||||||
Serial.println(configSetupJson.length());
|
Serial.println(configSetupJson.length());
|
||||||
Serial.println(F("--------------------------------------"));
|
Serial.println(F("--------------------------------------"));
|
||||||
|
|
||||||
if (jsonWrite(configSetupJson, "name", "test value")) {
|
if (jsonWriteStr_(configSetupJson, "name", "test value")) {
|
||||||
Serial.println("write sucsess");
|
Serial.println("write sucsess");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user