Commit Graph

49 Commits

Author SHA1 Message Date
acidburns def09160d0 refactor lora payload timing
Bump the batch payload codec to schema v4 with separate meter-time and UTC anchors, then use meter seconds for sparse batch slotting and receiver reconstruction.

Update the current 868 MHz bench configuration, allow ACKs from configured receiver short IDs, improve AP-to-STA recovery, quiet the test build, and document the changed protocol in the README.
2026-06-30 12:19:27 +02:00
acidburns 5edb79f372 refactor(build): consolidate envs to production/debug/test; add compiler hardening flags
- Replace 11 per-frequency build environments with 3 role-based targets
  (production, debug, test) using shared [env] base section
- Move LoRa frequency and sender-ID config from build flags into config.h
  so all variants build from the same source
- Add -fstack-protector-strong, -D_FORTIFY_SOURCE=2, -Wformat-security
- Add Unity test framework to lib_deps for pio test support
- Add __pycache__/ to .gitignore
2026-03-17 12:31:16 +01:00
acidburns b9591ce9bb feat(power): 1Hz chunked light-sleep; meter backoff; log throttling
- Replace delay() with light_sleep_chunked_ms() in sender idle path
  (100ms chunks preserve UART FIFO safety at 9600 baud)
- Add ENABLE_LIGHT_SLEEP_IDLE build flag (default: on, fallback: =0)
- Meter reader task: exponential backoff on consecutive poll failures
  (METER_FAIL_BACKOFF_BASE_MS..MAX_MS) to reduce idle Core-0 wakeups
- Configurable SENDER_DIAG_LOG_INTERVAL_MS (5s debug / 30s prod)
- Configurable METER_FRAME_TIMEOUT_CFG_MS, SENDER_CPU_MHZ
- New PlatformIO envs: lowpower, 868-lowpower, lowpower-debug
- Add docs/POWER_OPTIMIZATION.md with measurement plan and Go/No-Go
2026-03-16 16:32:49 +01:00
acidburns e89aee7048 Add WiFi reconnection retry logic to recover from unreliable WiFi
- Implement periodic WiFi reconnection attempts when stuck in AP mode
- Add WIFI_RECONNECT_INTERVAL_MS config (default 60s) for configurable retry frequency
- Prevent data loss by automatically attempting to switch back to STA mode
- Maintain AP mode for manual configuration if reconnection fails
- Track WiFi config and last reconnection attempt time in shared state
- Add wifi_try_reconnect_sta() and wifi_restore_ap_mode() helper functions
- Log reconnection attempts and results for debugging
2026-03-11 20:32:15 +01:00
acidburns 0577464ec5 refactor: stabilize legacy-core linking and header ownership
- Make include/ the canonical declarations for data_model/html_util/json_codec and convert dd3_legacy_core header copies to thin forwarders.
- Add stable public forwarders for app_context/receiver_pipeline/sender_state_machine and update refactor smoke test to stop using ../../src includes.
- Force-link dd3_legacy_core from setup() to ensure deterministic PlatformIO LDF linking across firmware envs.
- Refresh docs (README, Requirements, docs/TESTS.md) to reflect current module paths and smoke-test include strategy.
2026-02-20 23:29:50 +01:00
acidburns 9495e7e8de chore: unify HA manufacturer and add refactor guards 2026-02-18 02:25:07 +01:00
acidburns cc5881974c Add sender-local serial diagnostics for pipeline health 2026-02-17 01:12:31 +01:00
acidburns fea3749a93 Require AP web authentication by default 2026-02-17 00:39:44 +01:00
acidburns 16aad906a0 Harden receiver ingest against unknown senders 2026-02-17 00:30:06 +01:00
acidburns 5e27e2e7e8 Add meter Sekundenindex anchoring for epoch timestamps
Parse 0-0:96.8.0*255 meter seconds, derive sample epoch from anchored offset, and detect meter-time jumps via monotonic/delta checks.
2026-02-13 23:57:34 +01:00
acidburns 78a880e56f Track receiver duplicate batches in web and OLED 2026-02-13 23:57:34 +01:00
acidburns f65a6d28d9 Remove auto-reboot and make timezone configurable 2026-02-13 23:57:34 +01:00
acidburns 194c8a40cc Add detailed sender ACK RX diagnostics with reject context 2026-02-13 23:57:34 +01:00
acidburns 780cf8dc97 Use protocol constants for ACK airtime window sizing 2026-02-13 23:57:34 +01:00
acidburns a279c219ae Refactor LoRa protocol to batch+ack with ACK-based time bootstrap 2026-02-13 23:57:34 +01:00
acidburns 06847a9da4 Add RX reject reasons to telemetry and UI
BACKWARD-INCOMPATIBLE: MeterBatch schema bumped to v2 with err_rx_reject.
- Track and log RX reject reasons (CRC/protocol/role/payload/length/id/batch)
- Include rx_reject in sender telemetry JSON and receiver web UI
- Add lora_receive reject reason logging under SERIAL_DEBUG_MODE
2026-02-13 23:57:34 +01:00
acidburns 8681f37fc1 Repeat batch ACKs to cover RX latency
- Add ACK_REPEAT_COUNT/ACK_REPEAT_DELAY_MS and repeat ACK sends
- Update README with repeat-ACK behavior
2026-02-13 23:57:34 +01:00
acidburns deb060fd20 Add timesync burst handling and sender-only timeout
- Add TimeSync fault code and labels in UI/SD/web docs
- Trigger receiver beacon bursts on sender drift, but keep errors sender-local
- Sender flags TimeSync only after TIME_SYNC_ERROR_TIMEOUT_MS
2026-02-13 23:57:34 +01:00
acidburns 532a9154b1 Calibrate battery ADC and document LiPo curve
- Add BATTERY_CAL config and debug logging for raw ADC samples
- Use LiPo voltage curve (4.2V full, 2.9V empty) for % mapping
- Document battery calibration, curve, and debug output in README
2026-02-13 23:57:18 +01:00
acidburns e045673a3a Fix OLED autosleep timing and battery sampling cadence
- Track last OLED activity to avoid double timeout; keep power gating on transitions
- Copy TZ before setenv() in timegm_fallback to avoid invalid pointer reuse
- Add BATTERY_SAMPLE_INTERVAL_MS and only refresh cache at batch start when due
- Keep battery sampling to a single ADC read (Arduino core lacks explicit ADC power gating)
2026-02-13 23:57:18 +01:00
acidburns 532e51a76b Keep receiver LoRa in continuous RX
- Add lora_receive_continuous() helper and use it after init and TX (ACK/time sync)

- Ensure receiver returns to RX immediately after lora_send

- Document continuous RX behavior in README
2026-02-13 23:56:36 +01:00
acidburns 4b5c4e245e Make IEC 62056-21 meter input non-blocking
- Add RX state machine with frame buffer, timeouts, and debug counters

- Expose meter_poll_frame/meter_parse_frame and reuse existing OBIS parsing

- Use cached last-valid frame at 1 Hz sampling to avoid blocking

- Document non-blocking meter handling in README
2026-02-13 23:56:36 +01:00
acidburns 9c5b8fcdb4 Reduce sender power draw (RX windows + CPU/WiFi/ADC/pins)
- Add LoRa idle/sleep/receive-window helpers and use short RX windows for ACK/time sync

- Schedule sender time-sync windows (fast/slow) and track RX vs sleep time in debug

- Lower sender power (80 MHz CPU, WiFi/BT off, reduced ADC sampling, unused pins pulldown)

- Make SERIAL_DEBUG_MODE a build flag, add prod envs with debug off, and document changes
2026-02-13 23:56:36 +01:00
acidburns 4ff5fd1d55 Harden history device ID validation and SD download filename 2026-02-13 23:56:36 +01:00
acidburns bfcb2463c3 Harden web UI auth, input handling, and SD path validation
- Add optional Basic Auth with NVS-backed credentials and STA/AP flags; protect status, wifi, history, and download routes

- Stop pre-filling WiFi/MQTT/Web UI password fields; keep stored secrets on blank and add clear-password checkboxes

- Add HTML escaping + URL encoding helpers and apply to user-controlled strings; add unit test

- Harden /sd/download path validation (prefix, length, dotdot, slashes) and log rejections

- Enforce protocol version in LoRa receive and release GPIO14 before SD init

- Update README security, SD, and GPIO sharing notes
2026-02-13 23:56:36 +01:00
acidburns da16c59690 Add SD history UI and pin remap
- Add SD history chart + download listing to web UI
- Use HSPI for SD and fix SD pin mapping
- Swap role/OLED control pins and update role detection
- Update README pin mapping and SD/history docs
2026-02-13 23:56:36 +01:00
acidburns 6b1ed5b557 Move AP credentials to config and clarify STA UI access 2026-02-13 23:56:36 +01:00
acidburns ff6ade2760 Add SD logging and update docs
- Add optional microSD CSV logging per sender/day on receiver
- Wire logger into receiver packet handling
- Document new batch header fields, build envs, and SD logging
- Make sender links open in a new tab
2026-02-13 23:56:36 +01:00
acidburns 8ce5f4bc31 Tidy sender page layout and use SF12 2026-02-13 23:56:36 +01:00
acidburns e229efd427 Add payload codec test envs and enable serial debug 2026-02-13 23:56:36 +01:00
acidburns ea68ec699b Update README for binary batch payload and SF11 2026-02-13 23:56:36 +01:00
acidburns e84cd999b2 expand web ui with batch table and manual 2026-02-13 23:56:36 +01:00
acidburns 6e3ea1f50a document batching updates and restore bat_v in batches 2026-02-13 23:56:36 +01:00
acidburns cb7527ceeb increase lora throughput and improve receiver display 2026-02-13 23:56:36 +01:00
acidburns cd913d4e50 add lora send bypass for debugging 2026-02-13 23:56:36 +01:00
acidburns 8050992817 prevent watchdog from killing while printing json 2026-02-13 23:56:36 +01:00
acidburns 934012cacd serial debugging console implemented, enable via config.h 2026-02-13 23:56:36 +01:00
acidburns d5487e8c5f Add sender queue display and batch timing 2026-02-13 23:56:36 +01:00
acidburns 68542046de Update ESP32 platform and LoRa batching 2026-02-13 23:56:36 +01:00
acidburns 3840c00f2a Update batch schema and add ACK handling 2026-02-13 23:56:36 +01:00
acidburns 1279645812 Add LoRa telemetry, fault counters, and time sync status 2026-02-13 23:56:36 +01:00
acidburns ce0ee77f77 optional RTC 3231 integration 2026-01-29 22:15:50 +01:00
acidburns e480677b49 Add IEC62056 parsing, OLED timing, and batch LoRa send 2026-01-28 01:23:45 +01:00
acidburns 449fff1f06 Keep sender OLED on longer; faster page cycle 2026-01-27 22:56:37 +01:00
acidburns ae6e7b3192 Power down OLED before deep sleep 2026-01-23 17:14:16 +01:00
acidburns 770a021eca Sleep LoRa before sender deep sleep 2026-01-23 17:00:51 +01:00
acidburns 5f42575b10 Add 868MHz envs, fix MAC id, offset timesync 2026-01-21 21:14:48 +01:00
acidburns 8c9520f7e5 feat(battery): round bat_v and derive bat_pct locally 2026-01-20 22:58:56 +01:00
acidburns 6f308ad590 Initial commit 2026-01-20 01:39:06 +01:00