mirror of
https://github.com/IoTManagerProject/IoTManager.git
synced 2026-03-30 20:09:14 +03:00
logging class working vector
This commit is contained in:
@@ -3,8 +3,8 @@
|
||||
"chipID": "",
|
||||
"apssid": "IoTmanager",
|
||||
"appass": "",
|
||||
"routerssid": "rise",
|
||||
"routerpass": "hostel3333",
|
||||
"routerssid": "VOLODYA",
|
||||
"routerpass": "BELCHENKO",
|
||||
"timezone": 2,
|
||||
"ntp": "pool.ntp.org",
|
||||
"mqttServer": "91.204.228.124",
|
||||
|
||||
@@ -78,6 +78,7 @@
|
||||
"/set?addItem=uptime": "a.Отобразить время работы устройства"
|
||||
}
|
||||
},
|
||||
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
@@ -97,9 +98,6 @@
|
||||
"action": "/set?saveItems",
|
||||
"class": "btn btn-block btn-default"
|
||||
},
|
||||
{
|
||||
"type": "hr"
|
||||
},
|
||||
{
|
||||
"type": "link",
|
||||
"title": "Удалить выбранные элементы",
|
||||
@@ -112,6 +110,10 @@
|
||||
"action": "/set?delAllItems",
|
||||
"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",
|
||||
"title": "Сценарии"
|
||||
|
||||
@@ -30,6 +30,7 @@
|
||||
//
|
||||
#define TELEMETRY_UPDATE_INTERVAL_MIN 60
|
||||
|
||||
|
||||
//
|
||||
// Configuration
|
||||
//
|
||||
|
||||
@@ -129,3 +129,6 @@ extern void uptime_init();
|
||||
|
||||
// Web
|
||||
extern void web_init();
|
||||
|
||||
// Upgrade
|
||||
extern String serverIP;
|
||||
|
||||
@@ -3,6 +3,10 @@
|
||||
|
||||
#include "Global.h"
|
||||
|
||||
class LoggingClass;
|
||||
|
||||
typedef std::vector<LoggingClass> MyLoggingVector;
|
||||
|
||||
class LoggingClass {
|
||||
public:
|
||||
LoggingClass(unsigned long period, unsigned int maxPoints, String key);
|
||||
@@ -12,7 +16,6 @@ class LoggingClass {
|
||||
void writeDate();
|
||||
|
||||
private:
|
||||
|
||||
unsigned long currentMillis;
|
||||
unsigned long prevMillis;
|
||||
unsigned long difference;
|
||||
@@ -22,5 +25,4 @@ class LoggingClass {
|
||||
String _key;
|
||||
};
|
||||
|
||||
extern std::vector<LoggingClass*> myLogging;
|
||||
//extern LoggingClass* myLogging;
|
||||
extern MyLoggingVector* myLogging;
|
||||
|
||||
@@ -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;
|
||||
10
src/main.cpp
10
src/main.cpp
@@ -97,8 +97,11 @@ 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