diff --git a/README.md b/README.md index 45086f2..deab2bf 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ Firmware for LilyGO T3 v1.6.1 (`ESP32 + SX1276 + SSD1306`) that runs in two role - Batch payload codec is schema `v3` with a 30-bit `present_mask` over `[t_last-29, t_last]` (`src/payload_codec.cpp`). - Sender retries reuse cached encoded payload bytes (no re-encode on retry path). - Sender ACK receive windows adapt from observed ACK RTT + miss streak. +- Sender catch-up mode drains backlog with immediate extra sends when more than one batch is queued (still ACK-gated, single inflight batch). - Sender only starts normal metering/transmit flow after valid time bootstrap from receiver ACK. - Sender fault counters are reset at first valid time sync and again at each UTC hour boundary. - Receiver runs STA mode if stored config is valid and connects, otherwise AP fallback. @@ -90,6 +91,7 @@ Timestamp derivation: - jump checks: rollback, wall-time delta mismatch, anchor drift Sender builds sparse 30-slot windows and sends every `METER_SEND_INTERVAL_MS` (`30s`). +When backlog is present (`batch_q > 1`), sender transmits additional queued batches immediately after ACK to reduce lag, while keeping stop-and-wait ACK semantics. Sender diagnostics (serial debug mode): - periodic structured `diag:` line with: @@ -158,11 +160,13 @@ Web timestamp display: SD CSV logging (`src/sd_logger.cpp`): - 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_local` is local `HH:MM:SS` derived from `TIMEZONE_TZ` +- per-day file partition uses local date from `TIMEZONE_TZ`: `/dd3//YYYY-MM-DD.csv` History parser (`src/web_server.cpp`): - accepts both: - current layout (`ts_utc,ts_hms_local,p_w,...`) - legacy layout (`ts_utc,p_w,...`) +- daily file lookup prefers local-date filenames and falls back to legacy UTC-date filenames for backward compatibility - requires full numeric parse for `ts_utc` and `p_w` (rejects trailing junk) OLED duplicate display: diff --git a/Requirements.md b/Requirements.md index 02f3dfd..a47eeba 100644 --- a/Requirements.md +++ b/Requirements.md @@ -33,6 +33,7 @@ Function names below are C++ references. Rust naming/layout may differ, but the - Sampling/transmit cadence: - sender sample cadence 1 Hz. - sender batch cadence 30 s. + - when sender backlog exists (`batch_count > 1`) and no ACK is pending, sender performs immediate catch-up sends (still stop-and-wait with one inflight batch). - sync-request cadence 15 s while unsynced. - sender retransmits reuse cached encoded payload bytes for same inflight batch. - sender ACK receive window is adaptive from airtime + observed ACK RTT, with expanded second window on miss. @@ -53,6 +54,8 @@ Function names below are C++ references. Rust naming/layout may differ, but the - diagnostics do not change LoRa payload schema or remap payload fields. - SD logging: - CSV columns include both `ts_utc` and `ts_hms_local`. + - per-day CSV file partitioning uses local date (`TIMEZONE_TZ`) under `/dd3//YYYY-MM-DD.csv`. + - history day-file resolution prefers local-date filenames and falls back to legacy UTC-date filenames. - history parser supports both current (`ts_utc,ts_hms_local,p_w,...`) and legacy (`ts_utc,p_w,...`) layouts. ## 3. Protocol and Data Contracts @@ -246,11 +249,11 @@ Function names below are C++ references. Rust naming/layout may differ, but the - `void sd_logger_init()` - `bool sd_logger_is_ready()` - `void sd_logger_log_sample(const MeterData&, bool include_error_text)` - - append/create per-day CSV under `/dd3//YYYY-MM-DD.csv`. + - append/create per-day CSV under `/dd3//YYYY-MM-DD.csv` using local calendar date from `TIMEZONE_TZ`. - Internal behavior-critical helpers: - `fault_text` - `ensure_dir` - - `format_date_utc` + - `format_date_local` - `format_hms_local` ## `src/display_ui.cpp` @@ -309,7 +312,8 @@ Internal route/state functions to preserve behavior: - `sanitize_history_device_id` - `sanitize_download_filename` - `history_reset` -- `history_date_from_epoch` +- `history_date_from_epoch_local` +- `history_date_from_epoch_utc` (legacy fallback mapping) - `history_open_next_file` - `history_parse_line` - `history_tick` @@ -451,5 +455,7 @@ Suggested Rust primitives: - Duplicate batch handling updates counters and suppresses duplicate publish/log. - Web UI shows `epoch (HH:MM:SS TZ)` local time. - SD CSV header/fields match expected order. +- SD daily files roll over at local midnight (`TIMEZONE_TZ`), not UTC midnight. - History endpoint reads current and legacy CSV layouts successfully. +- History endpoint can read both local-date and legacy UTC-date day filenames. - MQTT state/fault payload fields match existing names and semantics.