From bffb708035dcc55a47b6b268a2e078cd8a63c292 Mon Sep 17 00:00:00 2001 From: ske087 Date: Thu, 6 Mar 2025 14:38:19 +0200 Subject: [PATCH] final --- Flask-monitoring/instance/logs.db | Bin 0 -> 20480 bytes sketch_test_button/sketch_test_button.ino | 3 - sketch_wifi/sketch_wifi.ino | 199 ---------------------- test_but/test_but.ino | 24 --- 4 files changed, 226 deletions(-) create mode 100644 Flask-monitoring/instance/logs.db delete mode 100644 sketch_test_button/sketch_test_button.ino delete mode 100644 sketch_wifi/sketch_wifi.ino delete mode 100644 test_but/test_but.ino diff --git a/Flask-monitoring/instance/logs.db b/Flask-monitoring/instance/logs.db new file mode 100644 index 0000000000000000000000000000000000000000..47f21ad8bb28f2e295c869bfe5207a71a30c7fcb GIT binary patch literal 20480 zcmeI4J#buC6~}j_T}ivrN(oK~0YWx_i4F1d{r*_A+{licII-nKQ49`{AltH|U`vj) zPGSRLmJ}2eE+{A{C{j?Q$YeB-A_WZv1qB5K1e zwfBF)-}&!5eXdoqGu0NZs!q&R@Kt_F50oA#Jy3d}^g!u>(gURjN)MDCC_PYmp!C3p z#smHR)!{q#?5Tb)_U2DtSh%o!9$y28XQ!v;rrUEiqeQ3oN~$w}?x6 z^A|6*AHZGbjvk-R!H>=!Jw7#is{P3HsrJ6bv-_L-^8|lj;@#Z$^@)Go_~Annh|-YK z1EmK_50oA#Jy3d}^g!u>(gURjN)MDCC_V81?t$7>cwn%b_vX8m*DDjhn0RTTJO1zS zH^;Az$JTqTH(JlP?AZ0OwXu~kIr`S4X+H#p|^%!8(JC?^?%gY>b<(Iy;J*n?S)zx{O91CgI5RRzgaYTy3AbymY3wxV*HubY2N%4+wog zxVDrXt2@GE!g*s|nxp{50H}@?S&+dQmA*&;90jUlpg>0l1sw|DDbOPG!33dFqyU}* z1qDJXB~zdPo&pI4R;lQdrvRP;p|j{hu)6C2kRJ@Anq9asf2FP3y~`_03uoIWjvOID zR2`uZ#Atm;mfoLZ044$qkWodI3tyMU<|)u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I9un?VT!DT7YOD1fH`QNT%8qxv2PuG~0GTHg=n&C7Izj6u?t}C`gAoj7WzlfTKX?wJ5viy@Dv~lGH>MS^d$=5DL@qRjK`Wh|G%yIhY#leSH^wo zoz`0Gxz@q4zm2^*wm5e0=$}Vl8J!=!8yA+J(gURjN)MDCC_PYmp!7iLfzkv2s~$-G zO}*wFkH_c?`3~ADC>?q4Qh)c&<{Jcy8X^jzHuX1kn|T`0SV4!*A!YCHzTLd80oCMS z&}ucQzp3BM(SX`Z%<@DDHMsun8_v)Gg2h{N-Xde|Z|XSnG$0lR<(~*Y?7ro^t^sv@ zytt)NitKOdIrB6i7CKsk*T?$1Z#u7QKrE2;qEVLmo4U>%4XD6CgL4M&!1Z_Ec7_HJ zph3C(<=6hEzB5k)Vu5#B-(v1Q2<8)sxVN1mx+Q)-=P4G0sx=@xp$1|+Z4c4fH){+6}olbq5z%( LgaNfQ)KUHevM7SY literal 0 HcmV?d00001 diff --git a/sketch_test_button/sketch_test_button.ino b/sketch_test_button/sketch_test_button.ino deleted file mode 100644 index b28b04f..0000000 --- a/sketch_test_button/sketch_test_button.ino +++ /dev/null @@ -1,3 +0,0 @@ - - - diff --git a/sketch_wifi/sketch_wifi.ino b/sketch_wifi/sketch_wifi.ino deleted file mode 100644 index b269ab7..0000000 --- a/sketch_wifi/sketch_wifi.ino +++ /dev/null @@ -1,199 +0,0 @@ -#include -#include -#include -#include "esp_mac.h" // required - exposes esp_mac_type_t values - -const char* ap_ssid = "ESP32-AP"; -const char* ap_password = "12345678"; -const int userLedPin = 8; // Define the pin for the user LED -const int buttonPin = 0; // Define the pin for the button - -WebServer server(80); - -String ssid, password, static_ip, hostname; -bool isAPMode = false; - -void handleRoot() { - String macAddress = getDefaultMacAddress(); - String html = "Configuration"; - html += ""; - html += "

Board Configuration

"; - html += "
"; - html += ""; - html += "
"; - html += ""; - html += "
"; - html += ""; - html += "
"; - html += ""; - html += "
"; - html += ""; - html += "
"; - html += ""; - html += "
"; - server.send(200, "text/html", html); -} - -void handleSave() { - ssid = server.arg("ssid"); - password = server.arg("password"); - static_ip = server.arg("static_ip"); - hostname = server.arg("hostname"); - - saveSettings(); - - server.send(200, "text/html", "Settings saved. Device will restart in client mode."); - delay(2000); - ESP.restart(); -} - -void handleInfo() { - String html = "Info"; - html += ""; - html += "

Connection Info

"; - if (WiFi.status() == WL_CONNECTED) { - html += "

Status: Connected

"; - html += "

IP Address: " + WiFi.localIP().toString() + "

"; - } else { - html += "

Status: Not Connected

"; - } - html += "
"; - server.send(200, "text/html", html); -} - -void saveSettings() { - EEPROM.writeString(0, ssid); - EEPROM.writeString(32, password); - EEPROM.writeString(64, static_ip); - EEPROM.writeString(96, hostname); - EEPROM.commit(); -} - -void loadSettings() { - ssid = EEPROM.readString(0); - password = EEPROM.readString(32); - static_ip = EEPROM.readString(64); - hostname = EEPROM.readString(96); -} - -void setup() { - Serial.begin(115200); - Serial.println("Setup started"); - EEPROM.begin(128); - - pinMode(userLedPin, OUTPUT); - digitalWrite(userLedPin, LOW); - - pinMode(buttonPin, INPUT_PULLUP); // Set the button pin as input with an internal pull-up resistor - - loadSettings(); - - // Stop AP mode if it was previously started - WiFi.softAPdisconnect(true); - - // Check if the button is pressed at startup - if (digitalRead(buttonPin) == LOW) { - Serial.println("Button pressed at startup. Starting in AP mode."); - startAPMode(); - } else { - if (ssid.length() > 0 && password.length() > 0) { - Serial.println("Attempting to connect to WiFi with saved credentials:"); - Serial.print("SSID: "); - Serial.println(ssid); - Serial.print("Password: "); - Serial.println(password); - WiFi.begin(ssid.c_str(), password.c_str()); - Serial.print("Connecting to WiFi"); - unsigned long startTime = millis(); - while (WiFi.status() != WL_CONNECTED) { - if (millis() - startTime >= 10000) { // 10 seconds timeout - Serial.println("Failed to connect to WiFi."); - startAPMode(); - return; - } - Serial.print("."); - delay(500); - } - Serial.println(); - Serial.println("Connected to WiFi."); - Serial.print("IP Address: "); - Serial.println(WiFi.localIP()); - Serial.print("Hostname: "); - Serial.println(hostname); - digitalWrite(userLedPin, HIGH); // Turn on the LED if connection is successful - isAPMode = false; - } else { - Serial.println("No saved WiFi credentials found. Starting in AP mode."); - startAPMode(); - } - } - Serial.println("Setup completed"); -} - -void loop() { - server.handleClient(); - blinkLed(); -} - -void blinkLed() { - static unsigned long lastBlinkTime = 0; - static bool ledState = LOW; - unsigned long interval = isAPMode ? 1000 : 3000; // 1 second interval for AP mode, 3 seconds for client mode - - if (millis() - lastBlinkTime >= interval) { - ledState = !ledState; - digitalWrite(userLedPin, ledState); - lastBlinkTime = millis(); - } -} - -void startAPMode() { - WiFi.softAP(ap_ssid, ap_password); - Serial.println("Access Point Started"); - Serial.print("IP Address: "); - Serial.println(WiFi.softAPIP()); - server.on("/", handleRoot); - server.on("/save", handleSave); - server.on("/info", handleInfo); - server.begin(); - isAPMode = true; -} - -String getDefaultMacAddress() { - String mac = ""; - unsigned char mac_base[6] = {0}; - - if (esp_efuse_mac_get_default(mac_base) == ESP_OK) { - char buffer[18]; // 6*2 characters for hex + 5 characters for colons + 1 character for null terminator - sprintf(buffer, "%02X:%02X:%02X:%02X:%02X:%02X", mac_base[0], mac_base[1], mac_base[2], mac_base[3], mac_base[4], mac_base[5]); - mac = buffer; - } - - return mac; -} - -String getInterfaceMacAddress(esp_mac_type_t interface) { - String mac = ""; - unsigned char mac_base[6] = {0}; - - if (esp_read_mac(mac_base, interface) == ESP_OK) { - char buffer[18]; // 6*2 characters for hex + 5 characters for colons + 1 character for null terminator - sprintf(buffer, "%02X:%02X:%02X:%02X:%02X:%02X", mac_base[0], mac_base[1], mac_base[2], mac_base[3], mac_base[4], mac_base[5]); - mac = buffer; - } - - return mac; -} \ No newline at end of file diff --git a/test_but/test_but.ino b/test_but/test_but.ino deleted file mode 100644 index 37e1922..0000000 --- a/test_but/test_but.ino +++ /dev/null @@ -1,24 +0,0 @@ -const int buttonPin = 0; // Assuming BUT1 is connected to GPIO 0 -const int ledPin = 8; // Assuming the user LED is connected to GPIO 8 -//test1 -void setup() { - Serial.begin(115200); - Serial.println("Setup started"); - pinMode(buttonPin, INPUT_PULLUP); // Set the button pin as input with an internal pull-up resistor - pinMode(ledPin, OUTPUT); // Set the LED pin as output - Serial.println("Setup completed"); -} - -void loop() { - int buttonState = digitalRead(buttonPin); // Read the state of the button - - if (buttonState == LOW) { - Serial.println("Button is pressed"); - digitalWrite(ledPin, HIGH); // Turn on the LED - } else { - Serial.println("Button is not pressed"); - digitalWrite(ledPin, LOW); // Turn off the LED - } - - delay(2000); // Add a 2-second delay between readings -} \ No newline at end of file