mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-26 22:22:16 +03:00
logging class working vector
This commit is contained in:
@@ -46,6 +46,9 @@ String sensorReadingMap30sec;
|
||||
String logging_value_names_list;
|
||||
int enter_to_logging_counter;
|
||||
|
||||
// Upgrade
|
||||
String serverIP = "http://206.189.49.244";
|
||||
|
||||
// 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 lastVersion;
|
||||
|
||||
@@ -33,9 +33,9 @@ void upgradeInit() {
|
||||
void getLastVersion() {
|
||||
if ((WiFi.status() == WL_CONNECTED)) {
|
||||
#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
|
||||
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
|
||||
if (tmp == "error") {
|
||||
lastVersion = -1;
|
||||
@@ -89,10 +89,10 @@ bool upgradeFS() {
|
||||
Serial.println("Start upgrade LittleFS, please wait...");
|
||||
#ifdef ESP8266
|
||||
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
|
||||
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
|
||||
if (retFS == HTTP_UPDATE_OK) { //если FS обновилась успешно
|
||||
SerialPrint("I", "Update", "LittleFS upgrade done!");
|
||||
@@ -108,10 +108,10 @@ bool upgradeBuild() {
|
||||
|
||||
#ifdef ESP8266
|
||||
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
|
||||
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
|
||||
|
||||
if (retBuild == HTTP_UPDATE_OK) { //если BUILD обновился успешно
|
||||
|
||||
@@ -70,7 +70,7 @@ String addNewDevice() {
|
||||
jsonWriteStr(json, "name", FIRMWARE_NAME);
|
||||
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.addHeader("Content-Type", "application/json");
|
||||
int httpCode = http.POST(json);
|
||||
@@ -103,7 +103,7 @@ String updateDevicePsn(String lat, String lon, String accur) {
|
||||
lonfl = lonfl + lonc;
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
http.begin(client, F("http://95.128.182.133:5055/"));
|
||||
http.begin(client, serverIP + F(":5055/"));
|
||||
http.setAuthorization("admin", "admin");
|
||||
http.addHeader("Content-Type", "application/json");
|
||||
String mac = WiFi.macAddress().c_str();
|
||||
@@ -132,7 +132,7 @@ String updateDeviceStatus() {
|
||||
if ((WiFi.status() == WL_CONNECTED)) {
|
||||
WiFiClient client;
|
||||
HTTPClient http;
|
||||
http.begin(client, F("http://95.128.182.133:5055/"));
|
||||
http.begin(client, serverIP + F(":5055/"));
|
||||
http.setAuthorization("admin", "admin");
|
||||
http.addHeader("Content-Type", "application/json");
|
||||
String mac = WiFi.macAddress().c_str();
|
||||
@@ -278,7 +278,7 @@ void updateDeviceList() {
|
||||
jsonWriteStr(json, "model", FIRMWARE_VERSION);
|
||||
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.addHeader("Content-Type", "application/json");
|
||||
int httpCode = http.PUT(json);
|
||||
|
||||
@@ -21,5 +21,4 @@ void LoggingClass::writeDate() {
|
||||
SerialPrint("I", "Logging", _key);
|
||||
}
|
||||
|
||||
std::vector<LoggingClass*> myLogging;
|
||||
//LoggingClass* myLogging;
|
||||
MyLoggingVector* myLogging= nullptr;
|
||||
12
src/main.cpp
12
src/main.cpp
@@ -96,9 +96,12 @@ void setup() {
|
||||
|
||||
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)
|
||||
|
||||
myLogging = new LoggingClass[1](5000, 200, "array");
|
||||
//myLogging = new LoggingClass(5000, 200, "test");
|
||||
|
||||
myLogging = new MyLoggingVector();
|
||||
myLogging->push_back(LoggingClass(5000, 1, "5 sec"));
|
||||
myLogging->push_back(LoggingClass(10000, 1, "10 sec"));
|
||||
|
||||
//myLogging->push_back(new LoggingClass());
|
||||
}
|
||||
|
||||
void loop() {
|
||||
@@ -121,5 +124,6 @@ void loop() {
|
||||
myNotAsyncActions->loop();
|
||||
ts.update();
|
||||
|
||||
myLogging->loop();
|
||||
myLogging->at(0).loop();
|
||||
myLogging->at(1).loop();
|
||||
}
|
||||
Reference in New Issue
Block a user