https://github.com/lostincompilation/prettyota
A better looking Web OTA updater for ESP32
https://github.com/lostincompilation/prettyota
Last synced: 12 months ago
JSON representation
A better looking Web OTA updater for ESP32
- Host: GitHub
- URL: https://github.com/lostincompilation/prettyota
- Owner: LostInCompilation
- License: zlib
- Created: 2025-02-22T22:02:31.000Z (about 1 year ago)
- Default Branch: main
- Last Pushed: 2025-03-02T06:29:42.000Z (12 months ago)
- Last Synced: 2025-03-02T07:24:04.118Z (12 months ago)
- Language: C++
- Size: 341 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE.md
Awesome Lists containing this project
README
### A modern looking OTA update server with easy rollback
## Features
- ***Drag and drop*** firmware or filesystem .bin file to start updating
- ***Rollback*** to previous firmware with one button click
- ***Show info*** about board (Firmware version, build time)
- Automatic ***reboot*** after update/rollback
- If needed enable **authentication** (username and password login)
## Usage
```cpp
#include
#include "PrettyOTA.hpp"
const char* WIFI_SSID = "YOUR_SSID";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
AsyncWebServer server(80);
PrettyOTA OTA;
void setup() {
// Initialize WiFi
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
// Initialize OTA
OTA.Begin(&server);
// Start web server
server.begin();
}
void loop() {
}
```
## Demo

## The Begin function
```cpp
PrettyOTA::Begin(Server, Username, Password, IsPasswordMD5Hash);
```
- Server: `AsyncWebServer*`
- Username: `const char*` *(Optional)*
- Password: `const char*` *(Optional)* - Can be normal text or an MD5 hash of the password
- IsPasswordMD5Hash: `bool` *(Optional) Default: false* - Set to `true` if the password is a MD5 hash
## Callbacks
You can define your own callbacks which get called by PrettyOTA:
```cpp
#include
#include "PrettyOTA.hpp"
const char* WIFI_SSID = "YOUR_SSID";
const char* WIFI_PASSWORD = "YOUR_WIFI_PASSWORD";
AsyncWebServer server(80);
PrettyOTA OTA;
void OnOTAStart()
{
Serial.println("OTA update started");
}
void OnOTAProgress(uint32_t currentSize, uint32_t totalSize)
{
Serial.printf("OTA Progress Current: %u bytes, Total: %u bytes\n", currentSize, totalSize);
}
void OnOTAEnd(bool successful)
{
if (successful)
Serial.println("OTA update finished successfully");
else
Serial.println("OTA update failed");
}
void setup() {
Serial.begin(9600);
// Initialize WiFi here
WiFi.begin(WIFI_SSID, WIFI_PASSWORD);
// Initialize OTA
OTAUpdates.Begin(&server, "admin", "123");
// Set callbacks
OTAUpdates.OnStart(OnOTAStart);
OTAUpdates.OnProgress(OnOTAProgress);
OTAUpdates.OnEnd(OnOTAEnd);
// Start web server
server.begin();
}
```