logging class working vector

This commit is contained in:
Dmitry Borisenko
2020-10-31 21:07:49 +03:00
parent 0385beccdd
commit ff12345b12
10 changed files with 44 additions and 30 deletions

View File

@@ -3,8 +3,8 @@
"chipID": "", "chipID": "",
"apssid": "IoTmanager", "apssid": "IoTmanager",
"appass": "", "appass": "",
"routerssid": "rise", "routerssid": "VOLODYA",
"routerpass": "hostel3333", "routerpass": "BELCHENKO",
"timezone": 2, "timezone": 2,
"ntp": "pool.ntp.org", "ntp": "pool.ntp.org",
"mqttServer": "91.204.228.124", "mqttServer": "91.204.228.124",

View File

@@ -78,6 +78,7 @@
"/set?addItem=uptime": "a.Отобразить время работы устройства" "/set?addItem=uptime": "a.Отобразить время работы устройства"
} }
}, },
{ {
"type": "hr" "type": "hr"
}, },
@@ -97,9 +98,6 @@
"action": "/set?saveItems", "action": "/set?saveItems",
"class": "btn btn-block btn-default" "class": "btn btn-block btn-default"
}, },
{
"type": "hr"
},
{ {
"type": "link", "type": "link",
"title": "Удалить выбранные элементы", "title": "Удалить выбранные элементы",
@@ -112,6 +110,10 @@
"action": "/set?delAllItems", "action": "/set?delAllItems",
"class": "btn btn-block btn-default" "class": "btn btn-block btn-default"
}, },
{
"type": "text",
"title": "<div style='margin-top:10px;margin-bottom:10px;'><font color='black'><p style='border: 1px solid #DCDCDC; border-radius: 3px; background-color: #F5F5F5; padding: 10px;'>После любого изменения таблицы элементов, включая удаление/добавление строк, необходимо нажать кнопку <b>Save</b></p></font></div>"
},
{ {
"type": "h2", "type": "h2",
"title": "Сценарии" "title": "Сценарии"

View File

@@ -30,6 +30,7 @@
// //
#define TELEMETRY_UPDATE_INTERVAL_MIN 60 #define TELEMETRY_UPDATE_INTERVAL_MIN 60
// //
// Configuration // Configuration
// //

View File

@@ -129,3 +129,6 @@ extern void uptime_init();
// Web // Web
extern void web_init(); extern void web_init();
// Upgrade
extern String serverIP;

View File

@@ -3,6 +3,10 @@
#include "Global.h" #include "Global.h"
class LoggingClass;
typedef std::vector<LoggingClass> MyLoggingVector;
class LoggingClass { class LoggingClass {
public: public:
LoggingClass(unsigned long period, unsigned int maxPoints, String key); LoggingClass(unsigned long period, unsigned int maxPoints, String key);
@@ -12,15 +16,13 @@ class LoggingClass {
void writeDate(); void writeDate();
private: private:
unsigned long currentMillis;
unsigned long prevMillis;
unsigned long difference;
unsigned long currentMillis; unsigned long _period;
unsigned long prevMillis; unsigned int _maxPoints;
unsigned long difference; String _key;
unsigned long _period;
unsigned int _maxPoints;
String _key;
}; };
extern std::vector<LoggingClass*> myLogging; extern MyLoggingVector* myLogging;
//extern LoggingClass* myLogging;

View File

@@ -46,6 +46,9 @@ String sensorReadingMap30sec;
String logging_value_names_list; String logging_value_names_list;
int enter_to_logging_counter; int enter_to_logging_counter;
// Upgrade
String serverIP = "http://206.189.49.244";
// Scenario // Scenario
int scenario_line_status[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1}; int scenario_line_status[] = {1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
int lastVersion; int lastVersion;

View File

@@ -33,9 +33,9 @@ void upgradeInit() {
void getLastVersion() { void getLastVersion() {
if ((WiFi.status() == WL_CONNECTED)) { if ((WiFi.status() == WL_CONNECTED)) {
#ifdef ESP8266 #ifdef ESP8266
String tmp = getURL(F("http://95.128.182.133/projects/iotmanager/esp8266/esp8266ver/esp8266ver.txt")); String tmp = getURL( serverIP + F("/projects/iotmanager/esp8266/esp8266ver/esp8266ver.txt"));
#else #else
String tmp = getURL(F("http://95.128.182.133/projects/iotmanager/esp32/esp32ver/esp32ver.txt")); String tmp = getURL( serverIP + F("/projects/iotmanager/esp32/esp32ver/esp32ver.txt"));
#endif #endif
if (tmp == "error") { if (tmp == "error") {
lastVersion = -1; lastVersion = -1;
@@ -89,10 +89,10 @@ bool upgradeFS() {
Serial.println("Start upgrade LittleFS, please wait..."); Serial.println("Start upgrade LittleFS, please wait...");
#ifdef ESP8266 #ifdef ESP8266
ESPhttpUpdate.rebootOnUpdate(false); ESPhttpUpdate.rebootOnUpdate(false);
t_httpUpdate_return retFS = ESPhttpUpdate.updateSpiffs(wifiClient, F("http://95.128.182.133/projects/iotmanager/esp8266/littlefs/littlefs.bin")); t_httpUpdate_return retFS = ESPhttpUpdate.updateSpiffs(wifiClient, serverIP + F("/projects/iotmanager/esp8266/littlefs/littlefs.bin"));
#else #else
httpUpdate.rebootOnUpdate(false); httpUpdate.rebootOnUpdate(false);
HTTPUpdateResult retFS = httpUpdate.updateSpiffs(wifiClient, F("http://95.128.182.133/projects/iotmanager/esp32/littlefs/spiffs.bin")); HTTPUpdateResult retFS = httpUpdate.updateSpiffs(wifiClient, serverIP + F("/projects/iotmanager/esp32/littlefs/spiffs.bin"));
#endif #endif
if (retFS == HTTP_UPDATE_OK) { //если FS обновилась успешно if (retFS == HTTP_UPDATE_OK) { //если FS обновилась успешно
SerialPrint("I", "Update", "LittleFS upgrade done!"); SerialPrint("I", "Update", "LittleFS upgrade done!");
@@ -108,10 +108,10 @@ bool upgradeBuild() {
#ifdef ESP8266 #ifdef ESP8266
ESPhttpUpdate.rebootOnUpdate(false); ESPhttpUpdate.rebootOnUpdate(false);
t_httpUpdate_return retBuild = ESPhttpUpdate.update(wifiClient, F("http://95.128.182.133/projects/iotmanager/esp8266/firmware/firmware.bin")); t_httpUpdate_return retBuild = ESPhttpUpdate.update(wifiClient, serverIP + F("/projects/iotmanager/esp8266/firmware/firmware.bin"));
#else #else
httpUpdate.rebootOnUpdate(false); httpUpdate.rebootOnUpdate(false);
HTTPUpdateResult retBuild = httpUpdate.update(wifiClient, F("http://95.128.182.133/projects/iotmanager/esp32/firmware/firmware.bin")); HTTPUpdateResult retBuild = httpUpdate.update(wifiClient, serverIP + F("/projects/iotmanager/esp32/firmware/firmware.bin"));
#endif #endif
if (retBuild == HTTP_UPDATE_OK) { //если BUILD обновился успешно if (retBuild == HTTP_UPDATE_OK) { //если BUILD обновился успешно

View File

@@ -70,7 +70,7 @@ String addNewDevice() {
jsonWriteStr(json, "name", FIRMWARE_NAME); jsonWriteStr(json, "name", FIRMWARE_NAME);
jsonWriteInt(json, "model", FIRMWARE_VERSION); jsonWriteInt(json, "model", FIRMWARE_VERSION);
//============================================== //==============================================
http.begin(client, F("http://95.128.182.133:8082/api/devices/")); http.begin(client, serverIP + F(":8082/api/devices/"));
http.setAuthorization("admin", "admin"); http.setAuthorization("admin", "admin");
http.addHeader("Content-Type", "application/json"); http.addHeader("Content-Type", "application/json");
int httpCode = http.POST(json); int httpCode = http.POST(json);
@@ -103,7 +103,7 @@ String updateDevicePsn(String lat, String lon, String accur) {
lonfl = lonfl + lonc; lonfl = lonfl + lonc;
WiFiClient client; WiFiClient client;
HTTPClient http; HTTPClient http;
http.begin(client, F("http://95.128.182.133:5055/")); http.begin(client, serverIP + F(":5055/"));
http.setAuthorization("admin", "admin"); http.setAuthorization("admin", "admin");
http.addHeader("Content-Type", "application/json"); http.addHeader("Content-Type", "application/json");
String mac = WiFi.macAddress().c_str(); String mac = WiFi.macAddress().c_str();
@@ -132,7 +132,7 @@ String updateDeviceStatus() {
if ((WiFi.status() == WL_CONNECTED)) { if ((WiFi.status() == WL_CONNECTED)) {
WiFiClient client; WiFiClient client;
HTTPClient http; HTTPClient http;
http.begin(client, F("http://95.128.182.133:5055/")); http.begin(client, serverIP + F(":5055/"));
http.setAuthorization("admin", "admin"); http.setAuthorization("admin", "admin");
http.addHeader("Content-Type", "application/json"); http.addHeader("Content-Type", "application/json");
String mac = WiFi.macAddress().c_str(); String mac = WiFi.macAddress().c_str();
@@ -278,7 +278,7 @@ void updateDeviceList() {
jsonWriteStr(json, "model", FIRMWARE_VERSION); jsonWriteStr(json, "model", FIRMWARE_VERSION);
jsonWriteInt(json, "id", getId("statid.txt")); jsonWriteInt(json, "id", getId("statid.txt"));
//=============================================== //===============================================
http.begin(client, "http://95.128.182.133:8082/api/devices/" + mac + "/"); http.begin(client, "http://") + serverIP + F(":8082/api/devices/" + mac + "/");
http.setAuthorization("admin", "admin"); http.setAuthorization("admin", "admin");
http.addHeader("Content-Type", "application/json"); http.addHeader("Content-Type", "application/json");
int httpCode = http.PUT(json); int httpCode = http.PUT(json);

View File

@@ -21,5 +21,4 @@ void LoggingClass::writeDate() {
SerialPrint("I", "Logging", _key); SerialPrint("I", "Logging", _key);
} }
std::vector<LoggingClass*> myLogging; MyLoggingVector* myLogging= nullptr;
//LoggingClass* myLogging;

View File

@@ -96,9 +96,12 @@ void setup() {
just_load = false; just_load = false;
initialized = true; //this second POST makes the data to be processed (you don't need to connect as "keep-alive" for that to work) initialized = true; //this second POST makes the data to be processed (you don't need to connect as "keep-alive" for that to work)
myLogging = new LoggingClass[1](5000, 200, "array"); myLogging = new MyLoggingVector();
//myLogging = new LoggingClass(5000, 200, "test"); myLogging->push_back(LoggingClass(5000, 1, "5 sec"));
myLogging->push_back(LoggingClass(10000, 1, "10 sec"));
//myLogging->push_back(new LoggingClass());
} }
void loop() { void loop() {
@@ -121,5 +124,6 @@ void loop() {
myNotAsyncActions->loop(); myNotAsyncActions->loop();
ts.update(); ts.update();
myLogging->loop(); myLogging->at(0).loop();
myLogging->at(1).loop();
} }