diff --git a/libraries/ArduinoOTA/ArduinoOTA.cpp b/libraries/ArduinoOTA/ArduinoOTA.cpp index 83cc5c7905..566d32e03a 100644 --- a/libraries/ArduinoOTA/ArduinoOTA.cpp +++ b/libraries/ArduinoOTA/ArduinoOTA.cpp @@ -349,6 +349,18 @@ void ArduinoOTAClass::_runUpdate() { } } +void ArduinoOTAClass::end() { + _initialized = false; + _udp_ota->unref(); + _udp_ota = 0; + if(_useMDNS){ + MDNS.end(); + } + _state = OTA_IDLE; + #ifdef OTA_DEBUG + OTA_DEBUG.printf("OTA server stopped.\n"); + #endif +} //this needs to be called in the loop() void ArduinoOTAClass::handle() { if (_state == OTA_RUNUPDATE) { diff --git a/libraries/ArduinoOTA/ArduinoOTA.h b/libraries/ArduinoOTA/ArduinoOTA.h index 323c8b73d5..d1a81a316e 100644 --- a/libraries/ArduinoOTA/ArduinoOTA.h +++ b/libraries/ArduinoOTA/ArduinoOTA.h @@ -62,6 +62,8 @@ class ArduinoOTAClass //Starts the ArduinoOTA service void begin(bool useMDNS = true); + //Ends the ArduinoOTA service + void end(); //Call this in loop() to run the service. Also calls MDNS.update() when begin() or begin(true) is used. void handle();