ota: add ota update capabilities

This commit is contained in:
2026-03-12 10:59:35 +01:00
parent b3485fcb10
commit ee3ec3ac4f
10 changed files with 1118 additions and 3 deletions

View File

@@ -135,6 +135,14 @@ GPIO pins can be configured in `main/config.h`. Modify the `bmc_gpio_defaults` a
| GET | `/api/system/info` | Get system information |
| GET | `/api/system/status` | Get BMC status |
### OTA Endpoints
| Method | Endpoint | Description |
|--------|----------|-------------|
| GET | `/api/ota/status` | Get OTA status and running partition |
| POST | `/api/ota/update` | Start OTA update from URL |
| POST | `/api/ota/upload` | Upload firmware file directly |
## Web Interface
Access the web interface by navigating to `http://<ip-address>/` in your browser.
@@ -144,6 +152,7 @@ Features:
- Real-time GPIO monitoring
- Serial console with WebSocket support
- System information display
- OTA firmware update
## Example Usage
@@ -175,11 +184,30 @@ ws.onmessage = (event) => console.log(event.data);
ws.send('command\n');
```
### OTA Firmware Update
```bash
# Check OTA status
curl http://192.168.1.100/api/ota/status
# Start OTA update from URL
curl -X POST http://192.168.1.100/api/ota/update \
-H "Content-Type: application/json" \
-d '{"url": "http://server/firmware.bin"}'
# Upload firmware file directly
curl -X POST http://192.168.1.100/api/ota/upload \
-F "firmware=@firmware.bin"
```
The web interface also supports drag-and-drop firmware upload - simply drag a `.bin` file onto the upload zone.
## Project Structure
```
esp32-bmc/
├── CMakeLists.txt # Project CMake configuration
├── partitions.csv # Partition table for OTA
├── sdkconfig.defaults # Default SDK configuration
├── .clang-format # Code formatter configuration
├── main/
@@ -190,6 +218,7 @@ esp32-bmc/
│ ├── uart_handler.c/h # UART serial communication
│ ├── ethernet_manager.c/h # W5500 Ethernet setup
│ ├── web_server.c/h # HTTP server and routes
│ ├── ota_handler.c/h # OTA update handling
│ └── html/
│ └── index.html # Web interface
└── README.md