Update docs for auth, time, discovery, and history changes

This commit is contained in:
2026-02-17 00:45:39 +01:00
parent fea3749a93
commit c33fb3274c
2 changed files with 44 additions and 17 deletions

View File

@@ -85,11 +85,13 @@ Sender builds sparse 30-slot windows and sends every `METER_SEND_INTERVAL_MS` (`
For decoded `BatchUp`: For decoded `BatchUp`:
1. Reassemble and decode. 1. Reassemble and decode.
2. Send `AckDown` immediately. 2. Validate sender identity (`EXPECTED_SENDER_IDS` and payload sender ID mapping).
3. Track duplicates per configured sender (`EXPECTED_SENDER_IDS`). 3. Reject unknown/mismatched senders before ACK and before SD/MQTT/web updates.
4. If duplicate: update duplicate counters/time, skip data write/publish. 4. Send `AckDown` promptly for accepted senders.
5. If `n==0`: sync request path only. 5. Track duplicates per configured sender.
6. Else reconstruct each sample timestamp from `t_last + present_mask`, then: 6. If duplicate: update duplicate counters/time, skip data write/publish.
7. If `n==0`: sync request path only.
8. Else reconstruct each sample timestamp from `t_last + present_mask`, then:
- append to SD CSV - append to SD CSV
- publish MQTT state - publish MQTT state
- update web status and last batch table - update web status and last batch table
@@ -113,25 +115,33 @@ State JSON (`src/json_codec.cpp`) includes:
Home Assistant discovery: Home Assistant discovery:
- enabled by `ENABLE_HA_DISCOVERY=true` - enabled by `ENABLE_HA_DISCOVERY=true`
- publishes to `homeassistant/sensor/<device_id>/<key>/config` - publishes to `homeassistant/sensor/<device_id>/<key>/config`
- `unique_id` format is `<device_id>_<key>` (example: `dd3-F19C_energy`)
- device metadata:
- `identifiers: ["<device_id>"]`
- `name: "<device_id>"`
- `model: "DD3-LoRa-Bridge"`
- `manufacturer: "AcidBurns"`
## Web UI, Wi-Fi, SD ## Web UI, Wi-Fi, SD
- Wi-Fi/MQTT/NTP/web-auth config is stored in Preferences. - Wi-Fi/MQTT/NTP/web-auth config is stored in Preferences.
- AP fallback SSID prefix: `DD3-Bridge-`. - AP fallback SSID prefix: `DD3-Bridge-`.
- Default web credentials: `admin/admin`. - Default web credentials: `admin/admin`.
- AP auth requirement is controlled by `WEB_AUTH_REQUIRE_AP` (default `false`). - AP auth requirement is controlled by `WEB_AUTH_REQUIRE_AP` (default `true`).
- STA auth requirement is controlled by `WEB_AUTH_REQUIRE_STA` (default `true`). - STA auth requirement is controlled by `WEB_AUTH_REQUIRE_STA` (default `true`).
Web timestamp display: Web timestamp display:
- human-facing timestamps show `epoch (HH:MM:SS TZ)` in local configured timezone. - human-facing timestamps show `epoch (HH:MM:SS TZ)` in local configured timezone.
SD CSV logging (`src/sd_logger.cpp`): SD CSV logging (`src/sd_logger.cpp`):
- header: `ts_utc,ts_hms_utc,p_w,p1_w,p2_w,p3_w,e_kwh,bat_v,bat_pct,rssi,snr,err_m,err_d,err_tx,err_last` - header: `ts_utc,ts_hms_local,p_w,p1_w,p2_w,p3_w,e_kwh,bat_v,bat_pct,rssi,snr,err_m,err_d,err_tx,err_last`
- `ts_hms_utc` is UTC `HH:MM:SS` - `ts_hms_local` is local `HH:MM:SS` derived from `TIMEZONE_TZ`
History parser (`src/web_server.cpp`): History parser (`src/web_server.cpp`):
- expects the current CSV layout above - accepts both:
- legacy CSV layouts are not parsed (no backward compatibility) - current layout (`ts_utc,ts_hms_local,p_w,...`)
- legacy layout (`ts_utc,p_w,...`)
- requires full numeric parse for `ts_utc` and `p_w` (rejects trailing junk)
OLED duplicate display: OLED duplicate display:
- receiver sender-pages show duplicate rate as `pct (absolute)` and last duplicate as `HH:MM`. - receiver sender-pages show duplicate rate as `pct (absolute)` and last duplicate as `HH:MM`.

View File

@@ -34,15 +34,19 @@ Function names below are C++ references. Rust naming/layout may differ, but the
- sync-request cadence 15 s while unsynced. - sync-request cadence 15 s while unsynced.
- Receiver behavior: - Receiver behavior:
- decode/reconstruct sparse timestamps. - decode/reconstruct sparse timestamps.
- ACK each decoded batch promptly. - ACK accepted batches promptly.
- reject unknown/mismatched sender identities before ACK and before SD/MQTT/web updates.
- update MQTT, web status, SD logging. - update MQTT, web status, SD logging.
- Persistence: - Persistence:
- Wi-Fi/MQTT/NTP/web credentials in Preferences namespace `dd3cfg`. - Wi-Fi/MQTT/NTP/web credentials in Preferences namespace `dd3cfg`.
- Web auth defaults:
- `WEB_AUTH_REQUIRE_STA=true`
- `WEB_AUTH_REQUIRE_AP=true`
- Web and display time rendering: - Web and display time rendering:
- local timezone from `TIMEZONE_TZ`. - local timezone from `TIMEZONE_TZ`.
- SD logging: - SD logging:
- CSV columns include both `ts_utc` and `ts_hms_utc`. - CSV columns include both `ts_utc` and `ts_hms_local`.
- history parser expects this current layout. - history parser supports both current (`ts_utc,ts_hms_local,p_w,...`) and legacy (`ts_utc,p_w,...`) layouts.
## 3. Protocol and Data Contracts ## 3. Protocol and Data Contracts
@@ -58,7 +62,14 @@ Function names below are C++ references. Rust naming/layout may differ, but the
- Timestamp constraints: - Timestamp constraints:
- receiver rejects decoded data whose timestamps are below `MIN_ACCEPTED_EPOCH_UTC` - receiver rejects decoded data whose timestamps are below `MIN_ACCEPTED_EPOCH_UTC`
- CSV header (current required layout): - CSV header (current required layout):
- `ts_utc,ts_hms_utc,p_w,p1_w,p2_w,p3_w,e_kwh,bat_v,bat_pct,rssi,snr,err_m,err_d,err_tx,err_last` - `ts_utc,ts_hms_local,p_w,p1_w,p2_w,p3_w,e_kwh,bat_v,bat_pct,rssi,snr,err_m,err_d,err_tx,err_last`
- Home Assistant discovery contract:
- topic: `homeassistant/sensor/<device_id>/<key>/config`
- `unique_id`: `<device_id>_<key>`
- `device.identifiers`: `["<device_id>"]`
- `device.name`: `<device_id>`
- `device.model`: `DD3-LoRa-Bridge`
- `device.manufacturer`: `AcidBurns`
## 4. Module and Function Requirements ## 4. Module and Function Requirements
@@ -126,8 +137,9 @@ Function names below are C++ references. Rust naming/layout may differ, but the
- configure NTP servers and timezone env. - configure NTP servers and timezone env.
- `uint32_t time_get_utc()` - `uint32_t time_get_utc()`
- return epoch or `0` when not plausible. - return epoch or `0` when not plausible.
- updates "clock plausible" state independently from sync state.
- `bool time_is_synced()` - `bool time_is_synced()`
- sync status helper. - true only after explicit sync signals (NTP callback/status or trusted `time_set_utc`).
- `void time_set_utc(uint32_t)` - `void time_set_utc(uint32_t)`
- set system time and sync flags. - set system time and sync flags.
- `void time_get_local_hhmm(char*, size_t)` - `void time_get_local_hhmm(char*, size_t)`
@@ -136,6 +148,8 @@ Function names below are C++ references. Rust naming/layout may differ, but the
- `uint32_t time_get_last_sync_age_sec()` - `uint32_t time_get_last_sync_age_sec()`
- Internal behavior-critical helpers: - Internal behavior-critical helpers:
- `note_last_sync` - `note_last_sync`
- `mark_synced`
- `ntp_sync_notification_cb`
- `ensure_timezone_set` - `ensure_timezone_set`
## `src/lora_transport.cpp` ## `src/lora_transport.cpp`
@@ -202,12 +216,14 @@ Function names below are C++ references. Rust naming/layout may differ, but the
- `fault_text` - `fault_text`
- `mqtt_connect` - `mqtt_connect`
- `publish_discovery_sensor` - `publish_discovery_sensor`
- discovery payload uses canonical device identity fields and `manufacturer=AcidBurns`
## `src/wifi_manager.cpp` ## `src/wifi_manager.cpp`
- `void wifi_manager_init()` - `void wifi_manager_init()`
- `bool wifi_load_config(WifiMqttConfig&)` - `bool wifi_load_config(WifiMqttConfig&)`
- `bool wifi_save_config(const WifiMqttConfig&)` - `bool wifi_save_config(const WifiMqttConfig&)`
- returns `false` when any Preferences write/verify fails.
- `bool wifi_connect_sta(const WifiMqttConfig&, uint32_t timeout_ms)` - `bool wifi_connect_sta(const WifiMqttConfig&, uint32_t timeout_ms)`
- `void wifi_start_ap(const char*, const char*)` - `void wifi_start_ap(const char*, const char*)`
- `bool wifi_is_connected()` - `bool wifi_is_connected()`
@@ -223,7 +239,7 @@ Function names below are C++ references. Rust naming/layout may differ, but the
- `fault_text` - `fault_text`
- `ensure_dir` - `ensure_dir`
- `format_date_utc` - `format_date_utc`
- `format_hms_utc` - `format_hms_local`
## `src/display_ui.cpp` ## `src/display_ui.cpp`
@@ -395,6 +411,7 @@ These functions define end-to-end firmware behavior and must have equivalents:
- bootstrap guardrail, retry counts, schedule intervals, min accepted epoch. - bootstrap guardrail, retry counts, schedule intervals, min accepted epoch.
- Preserve CSV output layout exactly: - Preserve CSV output layout exactly:
- consumers (history parser and external tooling) depend on it. - consumers (history parser and external tooling) depend on it.
- preserve reader compatibility for both current and legacy layouts.
- Preserve enum meanings: - Preserve enum meanings:
- `FaultType`, `RxRejectReason`, `LoraMsgKind`. - `FaultType`, `RxRejectReason`, `LoraMsgKind`.
@@ -415,5 +432,5 @@ Suggested Rust primitives:
- Duplicate batch handling updates counters and suppresses duplicate publish/log. - Duplicate batch handling updates counters and suppresses duplicate publish/log.
- Web UI shows `epoch (HH:MM:SS TZ)` local time. - Web UI shows `epoch (HH:MM:SS TZ)` local time.
- SD CSV header/fields match expected order. - SD CSV header/fields match expected order.
- History endpoint reads only current CSV layout successfully. - History endpoint reads current and legacy CSV layouts successfully.
- MQTT state/fault payload fields match existing names and semantics. - MQTT state/fault payload fields match existing names and semantics.