From e10f061eb8830afd4d09312dce8adbf259c14a24 Mon Sep 17 00:00:00 2001 From: Simon Schmidt Date: Thu, 10 Jun 2021 20:06:58 +0200 Subject: [PATCH] timing --- README.md | 2 ++ src/main.cpp | 28 +++++++++++++++++++++++++--- 2 files changed, 27 insertions(+), 3 deletions(-) diff --git a/README.md b/README.md index cd23711..98861fe 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ ### Steps to run it +https://arduino-esp8266.readthedocs.io/en/latest/ota_updates/readme.html + ##### create "include/wifi_credentials.h" ```cpp diff --git a/src/main.cpp b/src/main.cpp index 6fd7f38..820f052 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -98,11 +98,15 @@ void setup_webserver() { } + + + void setup() { Serial.begin(115200); Serial.println("Booting"); WiFi.mode(WIFI_STA); WiFi.begin(ssid, password); + while (WiFi.waitForConnectResult() != WL_CONNECTED) { Serial.println("Connection Failed! Rebooting..."); delay(5000); @@ -112,10 +116,7 @@ void setup() { // setup OTA ArduinoOTA.setPort(8266); ArduinoOTA.setHostname("ESP_Treppenlicht"); - - // No authentication by default ArduinoOTA.setPassword("admin"); - // Password can be set with it's md5 value as well // MD5(admin) = 21232f297a57a5a743894a0e4a801fc3 // ArduinoOTA.setPasswordHash("21232f297a57a5a743894a0e4a801fc3"); @@ -160,10 +161,31 @@ void setup() { } +unsigned long i = 0; +unsigned long a = 0; +unsigned long s = 0; +float ard_ota_time = 0; +float server_handle = 0; void loop() { + a = micros(); ArduinoOTA.handle(); + ard_ota_time += micros()-a; + s = micros(); server.handleClient(); + server_handle += micros()-s; + + if(++i >= 10000) { + Serial.print("Mittlere Laufzeit\tOTA: "); + Serial.print(ard_ota_time/10000.0); + Serial.print("µs\tHTTP: "); + Serial.print(server_handle/10000.0); + Serial.println("µs"); + + ard_ota_time = 0; + server_handle = 0; + i = 0; + } } \ No newline at end of file