mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
json 6 version
This commit is contained in:
@@ -26,7 +26,7 @@
|
||||
"webpass": "admin",
|
||||
"MqttIn": "0",
|
||||
"MqttOut": "0",
|
||||
"blink": "0",
|
||||
"blink": "1",
|
||||
"oneWirePin": "2",
|
||||
"serverip": "http://206.189.49.244",
|
||||
"uart": "0",
|
||||
|
||||
@@ -46,7 +46,7 @@
|
||||
#define MYSENSORS
|
||||
#endif
|
||||
|
||||
#define JSON_BUFFER_SIZE 1024
|
||||
#define JSON_BUFFER_SIZE 4096
|
||||
#define NUM_BUTTONS 6
|
||||
#define MQTT_RECONNECT_INTERVAL 20000
|
||||
#define CHANGE_BROKER_AFTER 5
|
||||
@@ -104,7 +104,8 @@ enum TimerTask_t { WIFI_SCAN,
|
||||
UPTIME,
|
||||
UDP,
|
||||
SYGNAL,
|
||||
TIMES };
|
||||
TIMES,
|
||||
MYTEST };
|
||||
|
||||
enum NotAsyncActions {
|
||||
do_ZERO,
|
||||
|
||||
@@ -64,47 +64,63 @@
|
||||
|
||||
String jsonReadStr(String& json, String name) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
deserializeJson(doc, json);
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
return doc[name].as<String>();
|
||||
}
|
||||
|
||||
boolean jsonReadBool(String& json, String name) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
deserializeJson(doc, json);
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
return doc[name].as<bool>();
|
||||
}
|
||||
|
||||
int jsonReadInt(String& json, String name) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
deserializeJson(doc, json);
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
return doc[name].as<int>();
|
||||
}
|
||||
|
||||
//=================================================================================
|
||||
String jsonWriteStr(String& json, String name, String value) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
deserializeJson(doc, json);
|
||||
DynamicJsonDocument doc(json.length());
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
doc[name] = value;
|
||||
json = "";
|
||||
serializeJson(doc, json);
|
||||
return json;
|
||||
}
|
||||
|
||||
String jsonWriteBool(String& json, String name, boolean value) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
deserializeJson(doc, json);
|
||||
DynamicJsonDocument doc(json.length());
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
doc[name] = value;
|
||||
json = "";
|
||||
serializeJson(doc, json);
|
||||
return json;
|
||||
}
|
||||
|
||||
String jsonWriteInt(String& json, String name, int value) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
deserializeJson(doc, json);
|
||||
DynamicJsonDocument doc(json.length());
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
doc[name] = value;
|
||||
json = "";
|
||||
serializeJson(doc, json);
|
||||
return json;
|
||||
}
|
||||
|
||||
String jsonWriteFloat(String& json, String name, float value) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
deserializeJson(doc, json);
|
||||
DynamicJsonDocument doc(json.length());
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
doc[name] = value;
|
||||
json = "";
|
||||
serializeJson(doc, json);
|
||||
return json;
|
||||
}
|
||||
|
||||
|
||||
14
src/main.cpp
14
src/main.cpp
@@ -11,6 +11,7 @@
|
||||
#include "Global.h"
|
||||
#include "Init.h"
|
||||
#include "ItemsList.h"
|
||||
#include "MySensorsDataParse.h"
|
||||
#include "RemoteOrdersUdp.h"
|
||||
#include "SoftUART.h"
|
||||
#include "Telegram.h"
|
||||
@@ -18,7 +19,6 @@
|
||||
#include "Utils/StatUtils.h"
|
||||
#include "Utils/Timings.h"
|
||||
#include "Utils/WebUtils.h"
|
||||
#include "MySensorsDataParse.h"
|
||||
#include "items/ButtonInClass.h"
|
||||
#include "items/vCountDown.h"
|
||||
#include "items/vImpulsOut.h"
|
||||
@@ -29,10 +29,10 @@
|
||||
#include "items/vSensorCcs811.h"
|
||||
#include "items/vSensorDallas.h"
|
||||
#include "items/vSensorDht.h"
|
||||
#include "items/vSensorNode.h"
|
||||
#include "items/vSensorPzem.h"
|
||||
#include "items/vSensorUltrasonic.h"
|
||||
#include "items/vSensorUptime.h"
|
||||
#include "items/vSensorNode.h"
|
||||
|
||||
void not_async_actions();
|
||||
|
||||
@@ -83,6 +83,16 @@ void setup() {
|
||||
|
||||
just_load = false;
|
||||
initialized = true;
|
||||
|
||||
const int capacity = JSON_OBJECT_SIZE(35);
|
||||
SerialPrint("I", F("Test"), String(capacity));
|
||||
|
||||
ts.add(
|
||||
MYTEST, 10000, [&](void*) {
|
||||
Serial.println(configSetupJson.length());
|
||||
},
|
||||
nullptr, true);
|
||||
|
||||
SerialPrint("I", F("System"), F("✔ Initialization completed"));
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user