Collection of code for ESP8266 devices
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

autoupdate.h 1.1KB

1234567891011121314151617181920212223242526272829303132333435363738
  1. #ifdef WITH_AUTOUPDATE
  2. String checkForUpdate() {
  3. String update_status;
  4. update_status = millis();
  5. // Don't run if wifi isn't connected...
  6. if ( WiFi.status() != WL_CONNECTED ) {
  7. update_status += F(": Wifi not connected. Skipping update check\n");
  8. return update_status;
  9. }
  10. update_status += F(": Checking for update...\n");
  11. BearSSL::WiFiClientSecure UpdateClient;
  12. UpdateClient.setInsecure();
  13. t_httpUpdate_return result = ESPhttpUpdate.update(UpdateClient, F("https://10.1.1.93/arduino/update/"));
  14. //WiFiClient UpdateClient;
  15. //t_httpUpdate_return result = ESPhttpUpdate.update(UpdateClient, F("http://10.1.1.93/arduino/update/"));
  16. switch(result) {
  17. case HTTP_UPDATE_FAILED:
  18. update_status += F(" - Update failed: ");
  19. update_status += ESPhttpUpdate.getLastError();
  20. update_status += F(" - Error: ");
  21. update_status += ESPhttpUpdate.getLastErrorString().c_str();
  22. update_status += F("\n");
  23. break;
  24. case HTTP_UPDATE_NO_UPDATES:
  25. update_status += F(" - No Update Available.\n");
  26. break;
  27. case HTTP_UPDATE_OK:
  28. update_status += F(" - Updated OK.\n");
  29. break;
  30. }
  31. return update_status;
  32. }
  33. #endif