Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
18 changes: 15 additions & 3 deletions libraries/ArduinoOTA/src/ArduinoOTA.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -122,11 +122,11 @@ void ArduinoOTAClass::begin() {
}

int ArduinoOTAClass::parseInt(){
char data[16];
char data[INT_BUFFER_SIZE];
uint8_t index = 0;
char value;
while(_udp_ota.peek() == ' ') _udp_ota.read();
while(true){
while(index < INT_BUFFER_SIZE - 1){
value = _udp_ota.peek();
if(value < '0' || value > '9'){
data[index++] = '\0';
Expand Down Expand Up @@ -347,15 +347,27 @@ void ArduinoOTAClass::_runUpdate() {
}
}

void ArduinoOTAClass::end() {
_initialized = false;
_udp_ota.stop();
if(_mdnsEnabled){
MDNS.end();
}
_state = OTA_IDLE;
#ifdef OTA_DEBUG
OTA_DEBUG.println("OTA server stopped.");
#endif
}

void ArduinoOTAClass::handle() {
if (_state == OTA_RUNUPDATE) {
_runUpdate();
_state = OTA_IDLE;
}
if(_udp_ota.parsePacket()){
_onRx();
_udp_ota.flush();
}
_udp_ota.flush(); // always flush, even zero length packets must be flushed.
}

int ArduinoOTAClass::getCommand() {
Expand Down
6 changes: 6 additions & 0 deletions libraries/ArduinoOTA/src/ArduinoOTA.h
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@
#include <functional>
#include "Update.h"

#define INT_BUFFER_SIZE 16


typedef enum {
OTA_IDLE,
OTA_WAITAUTH,
Expand Down Expand Up @@ -63,6 +66,9 @@ class ArduinoOTAClass
//Starts the ArduinoOTA service
void begin();

//Ends the ArduinoOTA service
void end();

//Call this in loop() to run the service
void handle();

Expand Down