Add maintenance API endpoints
This commit is contained in:
+129
-3
@@ -26,11 +26,15 @@ Current firmware version:
|
||||
|
||||
```text
|
||||
GET /
|
||||
GET /api/v1/health
|
||||
GET /api/v1/capabilities
|
||||
GET /api/v1/status
|
||||
GET /api/v1/config
|
||||
GET /api/v1/config/export
|
||||
|
||||
POST /api/v1/relay/set
|
||||
|
||||
POST /api/v1/config/import
|
||||
POST /api/v1/config/device
|
||||
POST /api/v1/config/relay
|
||||
POST /api/v1/config/temp
|
||||
@@ -75,6 +79,70 @@ POST /api/v1/relay/set
|
||||
|
||||
The dashboard is a client only. It may cache last-known values for display, but the Cargo ESP32 remains the source of truth for relay state, BMS state, alarms, and configuration.
|
||||
|
||||
## Health
|
||||
|
||||
### GET /api/v1/health
|
||||
|
||||
Returns a lightweight liveness response for dashboards and service tools.
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "health_response",
|
||||
"ok": true,
|
||||
"api_version": "v1",
|
||||
"firmware_name": "overland-controller",
|
||||
"firmware_version": "0.4.0",
|
||||
"uptime_seconds": 123,
|
||||
"network": {
|
||||
"ap_enabled": true,
|
||||
"ap_ip": "192.168.4.1",
|
||||
"sta_enabled": true,
|
||||
"sta_connected": false,
|
||||
"sta_ssid": "",
|
||||
"sta_ip": ""
|
||||
},
|
||||
"bms": {
|
||||
"configured": true,
|
||||
"connected": false
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Capabilities
|
||||
|
||||
### GET /api/v1/capabilities
|
||||
|
||||
Returns API and feature discovery data for clients.
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "capabilities_response",
|
||||
"ok": true,
|
||||
"api_version": "v1",
|
||||
"firmware_name": "overland-controller",
|
||||
"firmware_version": "0.4.0",
|
||||
"endpoints": [
|
||||
"GET /api/v1/status",
|
||||
"POST /api/v1/relay/set"
|
||||
],
|
||||
"limits": {
|
||||
"relay_count": 2,
|
||||
"temperature_sensor_count": 8,
|
||||
"runtime_temperature_status_count": 4,
|
||||
"wifi_network_count": 3
|
||||
},
|
||||
"features": {
|
||||
"relay_control": true,
|
||||
"temperature_scan": true,
|
||||
"wifi_config": true,
|
||||
"config_backup_restore": true,
|
||||
"bms_setup": true,
|
||||
"uart_json": true,
|
||||
"root_compatibility_aliases": true
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
## Status
|
||||
|
||||
### GET /api/v1/status
|
||||
@@ -261,19 +329,19 @@ Returns saved controller configuration.
|
||||
"address": "AA:BB:CC:DD:EE:FF",
|
||||
"address_type": "public"
|
||||
},
|
||||
"temperature_sensor_count": 4,
|
||||
"temperature_sensors": [
|
||||
{
|
||||
"id": "temp_1",
|
||||
"name": "Cabin",
|
||||
"address": "28:AA:BB:CC:DD:EE:FF:00",
|
||||
"enabled": true
|
||||
"enabled": true,
|
||||
"weather": false
|
||||
}
|
||||
]
|
||||
}
|
||||
```
|
||||
|
||||
Note: current `GET /api/v1/config` omits the `weather` field, while `/api/v1/status.config.temperature_sensors[]` includes it.
|
||||
|
||||
### POST /api/v1/config/device
|
||||
|
||||
Updates the controller display name.
|
||||
@@ -368,6 +436,63 @@ Clears saved configuration and restores firmware defaults.
|
||||
|
||||
Returns the reset config.
|
||||
|
||||
### GET /api/v1/config/export
|
||||
|
||||
Returns a backup envelope containing controller config and saved WiFi networks.
|
||||
|
||||
Important: export includes saved WiFi passwords so the backup can be restored. Treat the response as sensitive.
|
||||
|
||||
```json
|
||||
{
|
||||
"type": "config_export_response",
|
||||
"ok": true,
|
||||
"api_version": "v1",
|
||||
"firmware_name": "overland-controller",
|
||||
"firmware_version": "0.4.0",
|
||||
"config": {
|
||||
"device_name": "Overland Controller",
|
||||
"temperature_sensor_count": 4,
|
||||
"relays": [],
|
||||
"bms": {},
|
||||
"temperature_sensors": []
|
||||
},
|
||||
"wifi": {
|
||||
"networks": [
|
||||
{
|
||||
"index": 1,
|
||||
"ssid": "Starlink",
|
||||
"priority": 1,
|
||||
"password_set": true,
|
||||
"password": "password_here"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
### POST /api/v1/config/import
|
||||
|
||||
Restores a config backup. The preferred request shape is the same envelope returned by `GET /api/v1/config/export`.
|
||||
|
||||
```json
|
||||
{
|
||||
"config": {
|
||||
"device_name": "Overland Controller",
|
||||
"temperature_sensor_count": 4,
|
||||
"relays": [],
|
||||
"bms": {},
|
||||
"temperature_sensors": []
|
||||
},
|
||||
"wifi": {
|
||||
"networks": []
|
||||
}
|
||||
}
|
||||
```
|
||||
|
||||
The endpoint also accepts the bare config object without an outer `config` field. When `wifi.networks` is included, saved STA WiFi networks are replaced and persisted. It does not initiate STA reconnect; use `POST /api/v1/wifi/connect` after import if needed.
|
||||
|
||||
Returns the updated config.
|
||||
|
||||
## Relay Control
|
||||
|
||||
### POST /api/v1/relay/set
|
||||
@@ -671,6 +796,7 @@ Known error codes:
|
||||
|
||||
```text
|
||||
invalid_json
|
||||
invalid_config
|
||||
unknown_relay
|
||||
unknown_temp_sensor
|
||||
invalid_temp_selection
|
||||
|
||||
@@ -93,8 +93,12 @@ HTTP is the primary integration contract for:
|
||||
|
||||
Preferred direction:
|
||||
|
||||
GET /api/v1/health
|
||||
GET /api/v1/capabilities
|
||||
GET /api/v1/status
|
||||
GET /api/v1/config
|
||||
GET /api/v1/config/export
|
||||
POST /api/v1/config/import
|
||||
POST /api/v1/relay/set
|
||||
|
||||
Pre-versioned root routes remain registered as compatibility aliases for existing local clients.
|
||||
|
||||
@@ -166,6 +166,19 @@ After factory reset:
|
||||
- Temperature names return to generic defaults
|
||||
- BMS is unconfigured until selected or manually entered
|
||||
|
||||
## Backup And Restore
|
||||
|
||||
Configuration backup includes controller config and saved STA WiFi networks.
|
||||
|
||||
HTTP endpoints:
|
||||
|
||||
GET /api/v1/config/export
|
||||
POST /api/v1/config/import
|
||||
|
||||
`config/export` includes saved WiFi passwords so the backup can be restored. Treat exported JSON as sensitive.
|
||||
|
||||
`config/import` persists the restored config. If WiFi networks are imported, run `POST /api/v1/wifi/connect` afterward to attempt STA connection.
|
||||
|
||||
## Configuration Persistence
|
||||
|
||||
Configuration is stored using ESP32 non-volatile storage.
|
||||
|
||||
@@ -12,8 +12,12 @@ Control surfaces:
|
||||
|
||||
| Feature | USB Serial | UART JSON | HTTP API | Notes |
|
||||
|---|---:|---:|---:|---|
|
||||
| Health | No | No | Yes | `/api/v1/health` is lightweight HTTP liveness |
|
||||
| Capabilities | No | No | Yes | `/api/v1/capabilities` supports client discovery |
|
||||
| Status | Yes | Yes | Yes | `/api/v1/status` equals `status_request` |
|
||||
| Config view | Yes | Yes | Yes | `/api/v1/config` equals `config_request` |
|
||||
| Config export | No | No | Yes | `/api/v1/config/export` includes WiFi passwords |
|
||||
| Config import | No | No | Yes | `/api/v1/config/import` persists restored config |
|
||||
| Relay control | Yes | Yes | Yes | Preferred HTTP endpoint is `POST /api/v1/relay/set` |
|
||||
| Device name config | Yes | Yes | Yes | `devicename`, `config_device`, `/api/v1/config/device` |
|
||||
| Relay config | Yes | Yes | Yes | `relayname`, `config_relay`, `/api/v1/config/relay` |
|
||||
|
||||
@@ -47,11 +47,15 @@ All grounds remain common.
|
||||
## API endpoints consumed
|
||||
|
||||
Minimum dashboard MVP:
|
||||
- GET /api/v1/health
|
||||
- GET /api/v1/status
|
||||
- POST /api/v1/relay/set
|
||||
|
||||
Potential later use:
|
||||
- GET /api/v1/capabilities
|
||||
- GET /api/v1/config
|
||||
- GET /api/v1/config/export
|
||||
- POST /api/v1/config/import
|
||||
- POST /api/v1/config/save
|
||||
- POST /api/v1/temps/scan
|
||||
- POST /api/v1/temps/assign
|
||||
@@ -120,10 +124,11 @@ Then interactive:
|
||||
|
||||
1. Dashboard boots.
|
||||
2. Connects to cargo ESP32 AP.
|
||||
3. Polls GET /api/v1/status.
|
||||
4. Shows disconnected state until valid JSON is received.
|
||||
5. Updates dashboard on a fixed interval.
|
||||
6. Relay buttons call POST /api/v1/relay/set.
|
||||
3. Checks GET /api/v1/health.
|
||||
4. Polls GET /api/v1/status.
|
||||
5. Shows disconnected state until valid JSON is received.
|
||||
6. Updates dashboard on a fixed interval.
|
||||
7. Relay buttons call POST /api/v1/relay/set.
|
||||
|
||||
## Polling Guidance
|
||||
|
||||
|
||||
Reference in New Issue
Block a user