Add webota_delay() to handle OTA friendly delay() calls

This commit is contained in:
Scott Baker 2019-03-14 11:28:15 -07:00
parent 926844a420
commit a933ec00da
2 changed files with 16 additions and 0 deletions

View File

@ -148,3 +148,16 @@ int init_web_ota(WebServer *server) {
server->begin();
}
// If the MCU is in a delay() it cannot respond to HTTP OTA requests
// We do a "fake" looping delay and listen for incoming HTTP requests while waiting
void webota_delay(int ms) {
int last = millis();
extern WebServer OTAServer;
while ((millis() - last) < ms) {
OTAServer.handleClient();
delay(5);
}
}

View File

@ -1,6 +1,9 @@
#include <WebServer.h>
extern WebServer OTAServer;
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);