1
0
mirror of https://github.com/esp8266/Arduino.git synced 2025-06-12 01:53:07 +03:00

ArduinoOTA optimizations (#2445)

- Added option to control if the ESP should be rebooted on success
- Added delay before ESP.restart() is called
- Added some comments to the header
This commit is contained in:
Me No Dev
2016-08-27 18:32:26 +03:00
committed by GitHub
parent b41266097f
commit 889775c6fe
2 changed files with 41 additions and 3 deletions

View File

@ -30,18 +30,43 @@ class ArduinoOTAClass
ArduinoOTAClass();
~ArduinoOTAClass();
//Sets the service port. Default 8266
void setPort(uint16_t port);
//Sets the device hostname. Default esp8266-xxxxxx
void setHostname(const char *hostname);
String getHostname();
//Sets the password that will be required for OTA. Default NULL
void setPassword(const char *password);
//Sets the password as above but in the form MD5(password). Default NULL
void setPasswordHash(const char *password);
//Sets if the device should be rebooted after successful update. Default true
void setRebootOnSuccess(bool reboot);
//This callback will be called when OTA connection has begun
void onStart(THandlerFunction fn);
//This callback will be called when OTA has finished
void onEnd(THandlerFunction fn);
//This callback will be called when OTA encountered Error
void onError(THandlerFunction_Error fn);
//This callback will be called when OTA is receiving data
void onProgress(THandlerFunction_Progress fn);
//Starts the ArduinoOTA service
void begin();
//Call this in loop() to run the service
void handle();
int getCommand(); // get update command type after OTA started- either U_FLASH or U_SPIFFS
//Gets update command type after OTA has started. Either U_FLASH or U_SPIFFS
int getCommand();
private:
int _port;
@ -50,6 +75,7 @@ class ArduinoOTAClass
String _nonce;
UdpContext *_udp_ota;
bool _initialized;
bool _rebootOnSuccess;
ota_state_t _state;
int _size;
int _cmd;