ESP8266不仅可以通过IDE进行OTA,也可以通过具体网址进行OTA
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45
| #include <ESP8266httpUpdate.h>
WiFiClient UpdateClient;
void https_OTA() { while (1) { ESPhttpUpdate.onProgress([](int progress, int total) { Serial.printf("Progress: %d%%\n", (progress * 100) / total); strip.setPixelColor(((progress / (total / 100))) - 1, (progress / (total / 100)) / 100 * 255 * brightness / 100, (255 - (progress / (total / 100)) / 100 * 255) * brightness / 100, (255 - (progress / (total / 100)) / 100 * 255) * brightness / 100); strip.show(); });
t_httpUpdate_return ret = ESPhttpUpdate.update(UpdateClient, "http://xxxxxxxx/beta_0_0_1.bin"); switch (ret) { case HTTP_UPDATE_OK: Serial.println("Firmware updated successfully"); break; case HTTP_UPDATE_FAILED: Serial.println("Firmware update failed"); break; case HTTP_UPDATE_NO_UPDATES: Serial.println("No firmware updates available"); break; default: Serial.printf("Firmware update error %d\n", ret); break; } } }
|