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
|
||||
|
||||
Reference in New Issue
Block a user