Make ESP32 firmware API fully generic

This commit is contained in:
2026-06-04 03:33:36 -06:00
parent dc42284d87
commit cc1909faaf
8 changed files with 159 additions and 711 deletions
+37 -199
View File
@@ -6,79 +6,29 @@ Base URL while connected to the ESP32 access point:
http://192.168.4.1
---
## Status
### GET /status
Returns full controller status.
Returns full controller status, including battery/BMS telemetry, relay states, temperature sensor states, alarms, system info, and current configuration.
Includes:
- Battery/BMS telemetry
- Cell voltages
- Temperature readings
- Sensor health
- Relay states
- Vehicle state
- Network state
- Alarm state
- System info
- Current configuration
Relay states use generic relay IDs:
Relay states use generic IDs:
relay_1
relay_2
Temperature sensors use generic sensor IDs:
Temperature sensors use generic IDs:
temp_1
temp_2
temp_3
temp_4
temp_5
temp_6
temp_7
temp_8
---
temp_1 through temp_8
## Relay Control API
### GET /relay/relay_1/on
GET /relay/relay_1/on
GET /relay/relay_1/off
GET /relay/relay_2/on
GET /relay/relay_2/off
Turns relay 1 on.
### GET /relay/relay_1/off
Turns relay 1 off.
### GET /relay/relay_2/on
Turns relay 2 on.
### GET /relay/relay_2/off
Turns relay 2 off.
Relay display names are configurable. The firmware should not assume what a relay controls.
---
## Deprecated Relay Aliases
These legacy routes may still exist for compatibility during development, but should not be used by new clients:
/relay/starlink/on
/relay/starlink/off
/relay/fridge/on
/relay/fridge/off
Future work should remove these aliases after the Pico/dashboard clients use generic relay IDs.
---
Relay display names are configurable. Firmware and API clients should not assume what a relay controls.
## Configuration API
@@ -86,13 +36,9 @@ Future work should remove these aliases after the Pico/dashboard clients use gen
Returns saved configuration.
---
### POST /config/relay
Updates relay config.
Example body:
Example:
{
"id": "relay_1",
@@ -100,18 +46,9 @@ Example body:
"enabled": true
}
Valid IDs:
- relay_1
- relay_2
---
### POST /config/bms
Updates BMS config.
Example body:
Example:
{
"enabled": true,
@@ -120,13 +57,9 @@ Example body:
"address_type": "public"
}
---
### POST /config/temp
Updates temperature sensor config.
Example body:
Example:
{
"id": "temp_1",
@@ -135,24 +68,9 @@ Example body:
"enabled": true
}
Valid IDs:
- temp_1
- temp_2
- temp_3
- temp_4
- temp_5
- temp_6
- temp_7
- temp_8
---
### POST /config/factory-reset
Clears saved config and restores generic defaults.
---
Clears saved configuration and restores generic defaults.
## Serial Monitor
@@ -164,135 +82,59 @@ Line ending:
Newline
---
## Status and Config Commands
### status
Prints full JSON status to Serial.
### config
Prints current configuration to Serial.
### save
Saves current in-memory configuration to NVS.
### factory reset
Clears saved config and restores defaults.
---
status
config
save
factory reset
## Log Level Commands
### log quiet
Minimizes serial output.
### log info
Normal serial output.
### log debug
Enables recurring debug output.
---
log quiet
log info
log debug
## Relay Control Commands
Legacy relay control commands may still exist during development:
relay starlink on
relay starlink off
relay fridge on
relay fridge off
Future work should replace these with generic serial relay commands.
---
relay 1 on
relay 1 off
relay 2 on
relay 2 off
## Relay Configuration Commands
### relayname 1 Aux Power
Sets relay 1 display name.
### relayname 2 Accessory Power
Sets relay 2 display name.
relayname 1 Aux Power
relayname 2 Accessory Power
Run `save` after changing names.
---
## Temperature Sensor Configuration Commands
### tempname 1 Cabin
Sets temp sensor 1 display name.
### tempname 2 Outside Air
Sets temp sensor 2 display name.
tempname 1 Cabin
tempname 2 Outside Air
Run `save` after changing names.
---
## BMS Configuration Commands
### bmsname House Battery
Sets BMS display name.
### bmsaddr aa:bb:cc:dd:ee:ff
Sets BMS BLE address.
bmsname House Battery
bmsaddr aa:bb:cc:dd:ee:ff
Run `save` after changing BMS config manually.
---
## BMS Setup Mode Commands
### enter setup
Enters BMS setup mode.
Effects:
- Disconnects BMS client
- Pauses BMS reconnect
- Allows repeated BLE scans
### scan ble
Scans for BLE devices.
enter setup
scan ble
select bms 1
exit setup
Notes:
- Some BMS modules advertise intermittently.
- Multiple scans may be required.
### select bms 1
Selects BLE scan result 1 as the configured BMS.
This saves:
- BMS name
- BMS address
- BMS enabled state
### exit setup
Leaves BMS setup mode and allows BMS reconnect.
---
- Multiple BLE scans may be required.
- Once a BMS address is configured, BMS telemetry reconnects directly using the saved address.
## Typical First-Time Setup Flow
@@ -308,11 +150,7 @@ Leaves BMS setup mode and allows BMS reconnect.
save
config
---
## Known Notes
- BMS telemetry is reliable once a BMS address is configured.
- BLE discovery depends on how often the BMS advertises.
- DS18B20 sensors require a 4.7kΩ pull-up resistor on the 1-Wire data bus.
- Some legacy relay names still exist internally and should be removed in a future cleanup.
- The firmware uses generic relay and temperature IDs. Installation-specific names belong in saved configuration only.