From 962f9153b84263bf4c94edfb4516aa4433c485cb Mon Sep 17 00:00:00 2001 From: Scott Baker Date: Thu, 14 Mar 2019 14:50:29 -0700 Subject: [PATCH] Add an alternate if your HTTP server isn't OTAServer --- src/WebOTA.cpp | 10 ++++++++++ src/WebOTA.h | 2 ++ 2 files changed, 12 insertions(+) diff --git a/src/WebOTA.cpp b/src/WebOTA.cpp index 7d7347a..46b8454 100644 --- a/src/WebOTA.cpp +++ b/src/WebOTA.cpp @@ -161,3 +161,13 @@ void webota_delay(int ms) { delay(5); } } + +// Accept the HTTP server as a pointer +void webota_delay(int ms, WebServer *HTTPServer) { + int last = millis(); + + while ((millis() - last) < ms) { + HTTPServer->handleClient(); + delay(5); + } +} diff --git a/src/WebOTA.h b/src/WebOTA.h index 0c94026..2217b18 100644 --- a/src/WebOTA.h +++ b/src/WebOTA.h @@ -6,4 +6,6 @@ int init_wifi(const char *ssid, const char *password, const char *mdns_hostname) String ip2string(IPAddress ip); int init_mdns(const char *host); int init_web_ota(WebServer *server); + void webota_delay(int ms); +void webota_delay(int ms, WebServer *HTTPServer);