Files
Ardiuno/WS3/WS3-ESP32/ws3_ota.ino
2021-01-06 17:44:20 +01:00

37 lines
1.0 KiB
C++

// OTA stuff
// Setup OTA stuff
void setup_ota() {
//Port defaults to 8266
//ArduinoOTA.setPort(8266);
// Hostname defaults to projet name
ArduinoOTA.setHostname(Mqtt_clientid);
// No auth per default
ArduinoOTA.setPassword((const char *)OTAPASSWORD);
ArduinoOTA.onStart([]() {
Serial.println("OTA Update is Starting !");
});
ArduinoOTA.onEnd([]() {
Serial.println("\nOTA is done. Rebooting...");
});
ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
Serial.printf("Progress: %u%%\r", (progress / (total / 100)));
});
ArduinoOTA.onError([](ota_error_t error) {
Serial.printf("OTA Error[%u]: ", error);
if (error == OTA_AUTH_ERROR) Serial.println("Auth Failed");
else if (error == OTA_BEGIN_ERROR) Serial.println("Begin Failed");
else if (error == OTA_CONNECT_ERROR) Serial.println("Connect Failed");
else if (error == OTA_RECEIVE_ERROR) Serial.println("Receive Failed");
else if (error == OTA_END_ERROR) Serial.println("End Failed");
});
ArduinoOTA.begin();
}