Skip to content

Commit 1d5701b

Browse files
Phil1pphasenradball
authored andcommitted
Add ArduinoOTAClass::end() (esp8266#8379)
This adds the end() function for the ArduinoOTA class. ESP32 has this implemented, however ESP8266 was lacking this.
1 parent 22dfa16 commit 1d5701b

File tree

2 files changed

+14
-0
lines changed

2 files changed

+14
-0
lines changed

libraries/ArduinoOTA/ArduinoOTA.cpp

+12
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,18 @@ void ArduinoOTAClass::_runUpdate() {
349349
}
350350
}
351351

352+
void ArduinoOTAClass::end() {
353+
_initialized = false;
354+
_udp_ota->unref();
355+
_udp_ota = 0;
356+
if(_useMDNS){
357+
MDNS.end();
358+
}
359+
_state = OTA_IDLE;
360+
#ifdef OTA_DEBUG
361+
OTA_DEBUG.printf("OTA server stopped.\n");
362+
#endif
363+
}
352364
//this needs to be called in the loop()
353365
void ArduinoOTAClass::handle() {
354366
if (_state == OTA_RUNUPDATE) {

libraries/ArduinoOTA/ArduinoOTA.h

+2
Original file line numberDiff line numberDiff line change
@@ -62,6 +62,8 @@ class ArduinoOTAClass
6262
//Starts the ArduinoOTA service
6363
void begin(bool useMDNS = true);
6464

65+
//Ends the ArduinoOTA service
66+
void end();
6567
//Call this in loop() to run the service. Also calls MDNS.update() when begin() or begin(true) is used.
6668
void handle();
6769

0 commit comments

Comments
 (0)