feat: HAL variant system, OTA improvements, NVS migration scaffold
- Add variants/vesper.hpp and variants/agnus.hpp with HAS_SD_CARD, HAS_RTC, HAS_PCF8574, OUTPUT_COUNT_MAX, HW_FAMILY capability flags - Add agnus-v1 and agnus-mini-v1 PlatformIO environments with -include injection - Add src/NvsMigration/ scaffold for future NVS schema versioning - FirmwareHandler: OTA flow improvements and header updates - OTAManager: FastAPI integration, semver handling improvements - ConfigManager: refactoring groundwork for NVS-only variant support - CommunicationRouter: minor fix - provisioning/nvs_lab_device.csv: fix hw_type to VS, update device id fields - docs/dev/ota-telemetry-api.md: update API spec Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
@@ -16,22 +16,22 @@ The firmware POSTs two events during an OTA update. Both are **best-effort** —
|
||||
```json
|
||||
{
|
||||
"device_uid": "PV000000000000",
|
||||
"hw_type": "VS",
|
||||
"hw_version": "01",
|
||||
"hw_type": "vesper",
|
||||
"hw_version": "1.0",
|
||||
"from_version": "1.2.3",
|
||||
"to_version": "1.3.0",
|
||||
"channel": "stable"
|
||||
}
|
||||
```
|
||||
|
||||
| Field | Type | Description |
|
||||
|----------------|--------|--------------------------------------------------|
|
||||
| `device_uid` | string | Unique device identifier from NVS |
|
||||
| `hw_type` | string | Hardware type code (e.g. `VS`, `VP`, `VX`) |
|
||||
| `hw_version` | string | Hardware revision from NVS (e.g. `01`) |
|
||||
| `from_version` | string | Semver of the firmware currently running |
|
||||
| `to_version` | string | Semver of the firmware that was just downloaded |
|
||||
| `channel` | string | Update channel (`stable`, `beta`, etc.) |
|
||||
| Field | Type | Description |
|
||||
|----------------|--------|-----------------------------------------------------------------------|
|
||||
| `device_uid` | string | Unique device identifier from NVS |
|
||||
| `hw_type` | string | Hardware type code (e.g. `vesper`, `vesper-plus`, `vesper-pro`) |
|
||||
| `hw_version` | string | Hardware revision from NVS (e.g. `1.0`) |
|
||||
| `from_version` | string | Semver of the firmware currently running |
|
||||
| `to_version` | string | Semver of the firmware that was just downloaded |
|
||||
| `channel` | string | Update channel (`stable`, `beta`, etc.) |
|
||||
|
||||
### Expected Response
|
||||
|
||||
@@ -51,8 +51,8 @@ Any `2xx` status is accepted. Recommended: `204 No Content`.
|
||||
```json
|
||||
{
|
||||
"device_uid": "PV000000000000",
|
||||
"hw_type": "VS",
|
||||
"hw_version": "01",
|
||||
"hw_type": "vesper",
|
||||
"hw_version": "1.0",
|
||||
"from_version": "1.2.3",
|
||||
"to_version": "1.3.0",
|
||||
"channel": "stable",
|
||||
@@ -97,13 +97,15 @@ Any `2xx` status is accepted. Recommended: `204 No Content`.
|
||||
|
||||
### Background
|
||||
|
||||
The firmware sends its current version as a query parameter on every version check:
|
||||
The firmware sends its current version and hardware revision as query parameters on every version check:
|
||||
|
||||
```
|
||||
GET /api/firmware/{hw_type}/{channel}/latest?current_version=5.7.1
|
||||
GET /api/firmware/{hw_type}/{channel}/latest?hw_version=1.0¤t_version=5.7.1
|
||||
```
|
||||
|
||||
The server must use `current_version` to resolve upgrade chains and return the **correct next hop** rather than blindly returning the absolute latest. The device trusts whatever version the server returns and installs it.
|
||||
Both parameters are optional. The server must use `current_version` to resolve upgrade chains and return the **correct next hop** rather than blindly returning the absolute latest. The device trusts whatever version the server returns and installs it.
|
||||
|
||||
`hw_version` allows the server to filter firmware releases to those compatible with the device's specific hardware revision — useful when a hardware change between revisions requires a different binary.
|
||||
|
||||
**Example:** Device is on `5.7.1`. Latest is `7.2.2` but has `min_fw_version = 6.0.0`.
|
||||
- Without chain resolution → server returns `7.2.2` → device cannot install → update silently fails.
|
||||
@@ -113,7 +115,7 @@ The server must use `current_version` to resolve upgrade chains and return the *
|
||||
|
||||
### Changes needed in `/api/firmware/{hw_type}/{channel}/latest`
|
||||
|
||||
1. **Accept `current_version` as an optional query parameter** (string, semver format e.g. `5.7.1`). If absent or unparseable, fall back to current behaviour (return absolute latest).
|
||||
1. **Accept `hw_version` and `current_version` as optional query parameters** (both strings). If absent or unparseable, fall back to current behaviour (return absolute latest, no hw revision filtering).
|
||||
|
||||
2. **Resolve the next hop:**
|
||||
```
|
||||
@@ -135,6 +137,7 @@ WHERE hw_type = :hw_type
|
||||
AND channel = :channel
|
||||
AND version > :current_version
|
||||
AND (min_fw_version IS NULL OR :current_version >= min_fw_version)
|
||||
AND (min_hw_version IS NULL OR :hw_version >= min_hw_version) -- optional hw revision gate
|
||||
ORDER BY version ASC -- semver-aware sort
|
||||
LIMIT 1;
|
||||
```
|
||||
@@ -145,6 +148,7 @@ LIMIT 1;
|
||||
|
||||
| Scenario | Expected behaviour |
|
||||
|---|---|
|
||||
| `hw_version` absent / malformed | Ignore param, skip hw revision filtering |
|
||||
| `current_version` absent / malformed | Ignore param, return absolute latest (existing behaviour) |
|
||||
| Device already at latest | Return `404` or `200` with a "no update" indicator — firmware handles both |
|
||||
| No version satisfies the chain constraint | Return `404` — firmware logs and skips |
|
||||
|
||||
Reference in New Issue
Block a user