flok99

Untitled

Nov 10th, 2016
182
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.07 KB | None | 0 0
  1. #include <WiFiUdp.h>
  2. #include <ArduinoOTA.h>
  3.  
  4. // deze aanroepen vanuit setup()
  5. void enableOTA() {
  6. ArduinoOTA.setPort(8266);
  7. ArduinoOTA.setHostname(name); // aanpassen
  8. ArduinoOTA.setPassword(password); // aanpassen
  9.  
  10. ArduinoOTA.onStart([]() {
  11. Serial.println(F("OTA start"));
  12. });
  13. ArduinoOTA.onEnd([]() {
  14. Serial.println(F("OTA end"));
  15. });
  16. ArduinoOTA.onProgress([](unsigned int progress, unsigned int total) {
  17. Serial.printf("OTA progress: %u%%\r", (progress / (total / 100)));
  18. });
  19. ArduinoOTA.onError([](ota_error_t error) {
  20. Serial.printf("Error[%u]: ", error);
  21. if (error == OTA_AUTH_ERROR) Serial.println(F("Auth Failed"));
  22. else if (error == OTA_BEGIN_ERROR) Serial.println(F("Begin Failed"));
  23. else if (error == OTA_CONNECT_ERROR) Serial.println(F("Connect Failed"));
  24. else if (error == OTA_RECEIVE_ERROR) Serial.println(F("Receive Failed"));
  25. else if (error == OTA_END_ERROR) Serial.println(F("End Failed"));
  26. });
  27. ArduinoOTA.begin();
  28. Serial.println(F("Ready"));
  29. }
  30.  
  31. void loop() {
  32. ...
  33. ArduinoOTA.handle();
  34. ...
  35. }
Advertisement
Add Comment
Please, Sign In to add comment