An open API service indexing awesome lists of open source software.

https://github.com/ipdotsetaf/espasynchttpupdateserver

A Simple OTA web page implemented over ESPAsyncWebServer(by me-no-dev)
https://github.com/ipdotsetaf/espasynchttpupdateserver

async esp esp32 esp32-arduino esp8266 esp8266-arduino ota ota-update platformio webserver

Last synced: about 1 month ago
JSON representation

A Simple OTA web page implemented over ESPAsyncWebServer(by me-no-dev)

Awesome Lists containing this project

README

          









# ESP Async HTTP Update Server

This is an advanced version [ESP8266HTTPUpdateServer](https://github.com/esp8266/Arduino/tree/master/libraries/ESP8266HTTPUpdateServer)/[ESP32's HTTPUpdateServer](https://github.com/espressif/arduino-esp32/tree/master/libraries/HTTPUpdateServer) library, modified to be compatible with [ESPAsyncWebServer](https://github.com/me-no-dev/ESPAsyncWebServer) and also add optional Styling 🌈 to the page.

It will provide a webpage for updating the firmware/filesystem of `ESP8266` or `ESP32` microcontrollers.

> [!IMPORTANT]
> If you found this library helpful, please consider leaving a Star⭐
>
> It helps a lot in maintaining the project ❤️

## Features
- Supports:
- ESP8266
- ESP32
- Can Update:
- Firmware
- FileSystem
- Styling:
- Stylized (Additional ~350 bytes)
- Minimal
- Update modes:
- Firmware + FileSystem
- Firmware only
- FileSystem only
- Update route customization (default: `/update`)
- Update credentials customization (default: `No credentials`)
- Username
- Password
- Update Events:
- onUpdateBegin
- onUpdateEnd
- Force Aborting Update using events
- FileSystem Options:
- SPIFFS
- LittleFS

## HowTo

### Install

This Library is available in `Arduino Library Repository` and `PIO` and you can install it from:

| Arduino IDE Library Manager | PlatformIO Libraries |
|:---:|:---:|
|Arduino library manager|pltformio library|

`ipdotsetaf/ESPAsyncHTTPUpdateServer@^3.0.0`
### Setup
1. Include the library after `ESPAsyncWebServer.h`
``` C++
#include
#include
```
2. Create an object from `ESPAsyncHTTPUpdateServer`
``` C++
ESPAsyncHTTPUpdateServer updateServer;
AsyncWebServer server(80);
```
3. Setup the update server before starting the webServer
``` C++
updateServer.setup(&server);
server.begin();
```
#### Custom Route
``` C++
updateServer.setup(&server, "/customroute");
```
#### Credentials
``` C++
updateServer.setup(&server, "username", "password");
```
or
``` C++
updateServer.setup(&server, "/customroute", "username", "password");
```
#### Events
```c++
updateServer.onUpdateBegin = [](const UpdateType type, int &result)
{
//...
};

updateServer.onUpdateEnd = [](const UpdateType type, int &result)
{
//...
};
```
#### Aborting the update
```c++
updateServer.onUpdateBegin = [](const UpdateType type, int &result)
{
result = UpdateResult::UPDATE_ABORT;
};
```

### Styling and Customizing OTA Page

| Stylized | Minimal |
|:---:|:---:|
|Stylized OTA Page | Minimal OTA Page |

> [!IMPORTANT]
> By default styling is disabled to save ~350 bytes of flash memory.
>
> You can enable the styling by adding the `-DESPASYNCHTTPUPDATESERVER_PRETTY` Build Flag to your environment.

### Customizing OTA Page

> [!IMPORTANT]
> Add the `-DESPASYNCHTTPUPDATESERVER_MODE` Build Flag with desired value to choose different update mode.
> Choose the right value based on your needs from bellow table:
>
> | Update mode | value |
> |:---:|:---:|
> |Firmware and FileSystem|0|
> |Firmware only|1|
> |FileSystem only|2|

#### Modifying Htmls

in case you liked to modify the html of any of the pages, you need to run the `scripts/codeGenerator.py` afterwards so html contents get processed and placed in the source.

Instructions:
1. Make sure you have python installed
2. In your python environment run the following
3. `pip install -r requirements.txt`
4. `python codeGenerator.py`

### Selecting FileSystem
> [!IMPORTANT]
> The library's default fileSystem is `SPIFFS` but if you are using `LittleFS` for your FileSystem, make sure to add the `-DESPASYNCHTTPUPDATESERVER_LITTLEFS` Build Flag to your environment.

### Debugging
> [!TIP]
> To debug the library functionality, you can add the `-DESPASYNCHTTPUPDATESERVER_DEBUG` Build Flag to your environment.
>
> This will enable the library to print logs to the Serial.

> [!TIP]
> If you are using another `Serial` port, you can override the default serial by adding the `-DESPASYNCHTTPUPDATESERVER_SerialOutput=Serial1` Build Flag to your environment.

### Server Working Example

Please refer to this [fully working example](https://github.com/IPdotSetAF/ESPAsyncHTTPUpdateServer/blob/master/examples/simple_server/simple_server.ino)

## TODO:
- Custom CSS support
- Synchronous WebServer support

## Contribution
- You can open Issues for any bug report or feature request.
- You are free to contribute to this project by following these steps:
1. Fork this Repo.
2. Create a new branch for your feature/bugfix in your forked Repo.
3. Commit your changes to the new branch you just made.
4. Create a pull request from your branch into the `master` branch of This Repo([https://github.com/IPdotSetAF/ESPAsyncHTTPUpdateServer](https://github.com/IPdotSetAF/ESPAsyncHTTPUpdateServer)).