Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <WiFiUdp.h>
- #include <ArduinoOTA.h>
- // deze aanroepen vanuit setup()
- void enableOTA() {
- ArduinoOTA.setPort(8266);
- ArduinoOTA.setHostname(name); // aanpassen
- ArduinoOTA.setPassword(password); // aanpassen
- ArduinoOTA.onStart([]() {
- Serial.println(F("OTA start"));
- });
- ArduinoOTA.onEnd([]() {
- Serial.println(F("OTA end"));
- });
- ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
- Serial.printf("OTA progress: %u%%\r", (progress / (total / 100)));
- });
- ArduinoOTA.onError([](ota_error_t error) {
- Serial.printf("Error[%u]: ", error);
- if (error == OTA_AUTH_ERROR) Serial.println(F("Auth Failed"));
- else if (error == OTA_BEGIN_ERROR) Serial.println(F("Begin Failed"));
- else if (error == OTA_CONNECT_ERROR) Serial.println(F("Connect Failed"));
- else if (error == OTA_RECEIVE_ERROR) Serial.println(F("Receive Failed"));
- else if (error == OTA_END_ERROR) Serial.println(F("End Failed"));
- });
- ArduinoOTA.begin();
- Serial.println(F("Ready"));
- }
- void loop() {
- ...
- ArduinoOTA.handle();
- ...
- }
Advertisement
Add Comment
Please, Sign In to add comment