mirror of
https://github.com/esp8266/Arduino.git
synced 2025-06-07 16:23:38 +03:00
Add getCommand() api for OTA update type (#2259)
This commit is contained in:
parent
1f7989b31d
commit
c4f9f102ce
@ -326,4 +326,8 @@ void ArduinoOTAClass::handle() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
int ArduinoOTAClass::getCommand() {
|
||||||
|
return _cmd;
|
||||||
|
}
|
||||||
|
|
||||||
ArduinoOTAClass ArduinoOTA;
|
ArduinoOTAClass ArduinoOTA;
|
||||||
|
@ -40,6 +40,7 @@ class ArduinoOTAClass
|
|||||||
void onProgress(THandlerFunction_Progress fn);
|
void onProgress(THandlerFunction_Progress fn);
|
||||||
void begin();
|
void begin();
|
||||||
void handle();
|
void handle();
|
||||||
|
int getCommand(); // get update command type after OTA started- either U_FLASH or U_SPIFFS
|
||||||
|
|
||||||
private:
|
private:
|
||||||
int _port;
|
int _port;
|
||||||
|
@ -27,7 +27,14 @@ void setup() {
|
|||||||
// ArduinoOTA.setPassword((const char *)"123");
|
// ArduinoOTA.setPassword((const char *)"123");
|
||||||
|
|
||||||
ArduinoOTA.onStart([]() {
|
ArduinoOTA.onStart([]() {
|
||||||
Serial.println("Start");
|
String type;
|
||||||
|
if (ArduinoOTA.getCommand() == U_FLASH)
|
||||||
|
type = "sketch";
|
||||||
|
else // U_SPIFFS
|
||||||
|
type = "filesystem";
|
||||||
|
|
||||||
|
// NOTE: if updating SPIFFS this would be the place to unmount SPIFFS using SPIFFS.end()
|
||||||
|
Serial.println("Start updating " + type);
|
||||||
});
|
});
|
||||||
ArduinoOTA.onEnd([]() {
|
ArduinoOTA.onEnd([]() {
|
||||||
Serial.println("\nEnd");
|
Serial.println("\nEnd");
|
||||||
|
Loading…
x
Reference in New Issue
Block a user