mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 14:12:16 +03:00
Меняем unsigned long на long для _interval, для использования
отрицательных значений.
This commit is contained in:
@@ -139,7 +139,7 @@ extern Time_t _time_local;
|
||||
extern Time_t _time_utc;
|
||||
extern bool _time_isTrust;
|
||||
|
||||
extern unsigned long loopPeriod;
|
||||
//extern unsigned long loopPeriod;
|
||||
|
||||
// extern DynamicJsonDocument settingsFlashJsonDoc;
|
||||
// extern DynamicJsonDocument paramsFlashJsonDoc;
|
||||
|
||||
@@ -10,7 +10,7 @@ extern String jsonWriteInt(String& json, String name, int value, bool e = true);
|
||||
extern String jsonWriteFloat(String& json, String name, float value, bool e = true);
|
||||
extern String jsonWriteBool(String& json, String name, boolean value, bool e = true);
|
||||
|
||||
extern bool jsonRead(const String& json, String key, unsigned long& value, bool e = true);
|
||||
extern bool jsonRead(const String& json, String key, long& value, bool e = true);
|
||||
extern bool jsonRead(const String& json, String key, float& value, bool e = true);
|
||||
extern bool jsonRead(const String& json, String key, String& value, bool e = true);
|
||||
extern bool jsonRead(const String& json, String key, bool& value, bool e = true);
|
||||
|
||||
@@ -70,7 +70,7 @@ String mqttRootDevice = "";
|
||||
unsigned long unixTime = 0;
|
||||
unsigned long unixTimeShort = 0;
|
||||
|
||||
unsigned long loopPeriod;
|
||||
//unsigned long loopPeriod;
|
||||
|
||||
bool isTimeSynch = false;
|
||||
Time_t _time_local;
|
||||
|
||||
@@ -12,7 +12,7 @@ class ButtonIn : public IoTItem {
|
||||
String _pinMode;
|
||||
int _lastButtonState = LOW;
|
||||
unsigned long _lastDebounceTime = 0;
|
||||
unsigned long _debounceDelay = 50;
|
||||
long _debounceDelay = 50;
|
||||
int _buttonState;
|
||||
int _reading;
|
||||
|
||||
|
||||
@@ -22,7 +22,7 @@ class Loging : public IoTItem {
|
||||
String prevDate = "";
|
||||
bool firstTimeDate = true;
|
||||
|
||||
unsigned long interval;
|
||||
long interval;
|
||||
|
||||
public:
|
||||
Loging(String parameters) : IoTItem(parameters) {
|
||||
|
||||
@@ -21,7 +21,7 @@ class LogingDaily : public IoTItem {
|
||||
String prevDate = "";
|
||||
bool firstTimeDate = true;
|
||||
|
||||
unsigned long interval;
|
||||
long interval;
|
||||
|
||||
public:
|
||||
LogingDaily(String parameters) : IoTItem(parameters) {
|
||||
|
||||
@@ -11,21 +11,23 @@ void jsonWriteStrDoc(DynamicJsonDocument& doc, String name, String value) {
|
||||
}
|
||||
|
||||
// new==============================================================================
|
||||
bool jsonRead(const String& json, String key, unsigned long& value, bool e) {
|
||||
bool jsonRead(const String& json, String key, long& value, bool e) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
SerialPrint("EE", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
if (e) {
|
||||
SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
return false;
|
||||
} else if (!doc.containsKey(key)) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonRead"), key + " missing");
|
||||
SerialPrint("E", F("jsonRead"), key + " missing");
|
||||
jsonErrorDetected();
|
||||
}
|
||||
return false;
|
||||
}
|
||||
value = doc[key].as<unsigned long>();
|
||||
value = doc[key].as<long>();
|
||||
return true;
|
||||
}
|
||||
|
||||
@@ -33,12 +35,14 @@ bool jsonRead(const String& json, String key, float& value, bool e) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
SerialPrint("EE", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
if (e) {
|
||||
SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
return false;
|
||||
} else if (!doc.containsKey(key)) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonRead"), key + " missing");
|
||||
SerialPrint("E", F("jsonRead"), key + " missing");
|
||||
jsonErrorDetected();
|
||||
}
|
||||
return false;
|
||||
@@ -51,12 +55,14 @@ bool jsonRead(const String& json, String key, String& value, bool e) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
SerialPrint("EE", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
if (e) {
|
||||
SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
return false;
|
||||
} else if (!doc.containsKey(key)) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonRead"), key + " missing");
|
||||
SerialPrint("E", F("jsonRead"), key + " missing");
|
||||
jsonErrorDetected();
|
||||
}
|
||||
return false;
|
||||
@@ -76,12 +82,14 @@ bool jsonRead(const String& json, String key, int& value, bool e) {
|
||||
DynamicJsonDocument doc(JSON_BUFFER_SIZE);
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
SerialPrint("EE", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
if (e) {
|
||||
SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
return false;
|
||||
} else if (!doc.containsKey(key)) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonRead"), key + " missing");
|
||||
SerialPrint("E", F("jsonRead"), key + " missing");
|
||||
jsonErrorDetected();
|
||||
}
|
||||
return false;
|
||||
@@ -97,7 +105,7 @@ bool jsonWriteStr_(String& json, const String& key, const String& value, bool e)
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||
SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
ret = false;
|
||||
@@ -114,7 +122,7 @@ bool jsonWriteBool_(String& json, const String& key, bool value, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||
SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
ret = false;
|
||||
@@ -131,7 +139,7 @@ bool jsonWriteInt_(String& json, const String& key, int value, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||
SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
ret = false;
|
||||
@@ -148,7 +156,7 @@ bool jsonWriteFloat_(String& json, const String &key, float value, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||
SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
ret = false;
|
||||
@@ -177,7 +185,7 @@ bool jsonMergeObjects(String& json1, String& json2, bool e) {
|
||||
jsonMergeDocs(doc1.as<JsonObject>(), doc2.as<JsonObject>());
|
||||
if (error1 || error2) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("json"), "jsonMergeObjects error");
|
||||
SerialPrint("E", F("json"), "jsonMergeObjects error");
|
||||
jsonErrorDetected();
|
||||
}
|
||||
ret = false;
|
||||
@@ -199,7 +207,7 @@ String jsonReadStr(const String& json, String name, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonRead"), error.f_str());
|
||||
SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
}
|
||||
@@ -211,7 +219,7 @@ boolean jsonReadBool(const String& json, String name, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonRead"), error.f_str());
|
||||
SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
}
|
||||
@@ -223,7 +231,7 @@ int jsonReadInt(const String& json, String name, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonRead"), error.f_str());
|
||||
SerialPrint("E", F("jsonRead"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
}
|
||||
@@ -236,7 +244,7 @@ String jsonWriteStr(String& json, String name, String value, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||
SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
}
|
||||
@@ -251,7 +259,7 @@ String jsonWriteBool(String& json, String name, boolean value, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||
SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
}
|
||||
@@ -266,7 +274,7 @@ String jsonWriteInt(String& json, String name, int value, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||
SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
}
|
||||
@@ -281,7 +289,7 @@ String jsonWriteFloat(String& json, String name, float value, bool e) {
|
||||
DeserializationError error = deserializeJson(doc, json);
|
||||
if (error) {
|
||||
if (e) {
|
||||
SerialPrint("EE", F("jsonWrite"), error.f_str());
|
||||
SerialPrint("E", F("jsonWrite"), error.f_str());
|
||||
jsonErrorDetected();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -79,7 +79,7 @@ void hex2string(byte array[], unsigned int len, char buffer[]) {
|
||||
buffer[len * 2] = '\0';
|
||||
}
|
||||
|
||||
inline unsigned char ChartoHex(char ch) {
|
||||
unsigned char ChartoHex(char ch) {
|
||||
return ((ch >= 'A') ? (ch - 'A' + 0xA) : (ch - '0')) & 0x0F;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user