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