Commit Graph

9 Commits

Author SHA1 Message Date
Michael Holzmann 9ed43e36a1 fix: non-blocking BLE scan with stall recovery and BLE watchdog
- Scan with a completion callback instead of blocking start(); results
  are only cleared when the scanner is confirmed idle
- Stall detection per block; 2 stalls re-init NimBLE, 5 reboot the ESP32
- Reboot if BLE worked before and no valid packet for 30 min
- Diag counters: adv_total, mac_hits, victron_prefix, ble_stalls,
  ble_recoveries; log first foreign Victron address seen
- Log target MAC at scanner init
- Static scan callback instance (no leak on re-init)
2026-11-15 10:12:38 +00:00
Michael Holzmann 156f43323c feat: make WiFi power-save and HA discovery configurable
- WIFI_DISABLE_POWER_SAVE (default 1 = keep modem sleep off)
- HA_DISCOVERY_ENABLED: switch auto-discovery off entirely; the payload
  strings are compiled out, saving ~4.6 KB of flash
- HA_DISCOVERY_PREFIX, HA_DEVICE_ID, HA_UNIQUE_PREFIX, HA_DEVICE_NAME,
  HA_MODEL and HA_MANUFACTURER replace the hardcoded garage identifiers,
  so a second MPPT can run without entity/topic collisions
- Defaults reproduce the previous topics, unique_ids and payloads exactly
- Document the new options in README; all values remain #ifndef-guarded
  so existing config.h files keep compiling
2026-11-14 15:19:52 +00:00
Michael Holzmann a2fea10678 chore: harden shared state, parser bounds and build pinning
- Guard the AES output buffer against oversized advertisements
- Protect the cross-core MpptData hand-off with a critical section and
  publish from a consistent snapshot
- Scan in 30s blocks and clear results between them: NimBLE 1.4.x only
  frees its result list when a scan completes, and one entry is kept per
  unique BLE address (including MAC-randomising phones)
- Do not let the forced-reconnect watchdog reset the reboot watchdog
- Publish discovery immediately after a reconnect instead of waiting for
  the retry timer
- Pin espressif32 to 6.13.0 (Arduino core 2.0.17), the last platform
  compatible with NimBLE-Arduino 1.4.x
- Document diagnostics, watchdogs and the data_age_s field
2026-11-14 14:54:35 +00:00
Michael Holzmann 4cd4fbe41a fix: recover from WiFi/MQTT dead states
- Replace the blocking WiFi and MQTT connect loops with non-blocking
  retry-on-timer functions, so the MQTT task never parks forever on an
  unreachable broker
- Publish data on a fixed cadence as well as on new BLE packets, adding
  data_age_s so stale values are visible
- Track successful publishes; force an MQTT reconnect after 5 minutes
  without one (half-open TCP socket) and reboot after 60 minutes with no
  success at all
- Retry Home Assistant discovery every 30s until every config topic has
  been accepted instead of silently giving up
- MQTT keepalive 30s, socket timeout 5s, publish buffer 1024 bytes
2026-11-14 14:49:36 +00:00
Michael Holzmann 98ac623423 fix: stop BLE scan from starving WiFi
- Scan continuously with a 50% duty cycle (interval 100ms / window 50ms)
  instead of a 99% window that leaves almost no airtime for WiFi
- Drop the 5s scan / 10s idle loop cadence, which created regular 10s
  holes in BLE reception
- Restart the scan only when the controller reports it as stopped
- setMaxResults(0): callbacks only, no per-device allocations
- Disable WiFi modem sleep and auto-reconnect on
- Initialise WiFi before BLE and create the MQTT task afterwards so the
  two radio drivers are never brought up concurrently
2026-11-14 14:47:08 +00:00
Michael Holzmann 780df35131 feat: add runtime diagnostics
- Log WiFi association, IP and disconnect reason codes
- Publish solar/mppt/diag every 60s: uptime, WiFi status/RSSI, free and
  min-free heap, WiFi disconnect count, MQTT connect count, publish
  failures, BLE valid/ignored packet counts and BLE packet age
- Count and log failed MQTT data publishes instead of dropping silently
- Log failed BLE scan starts
- Document the new diag topic
2026-11-14 14:46:17 +00:00
MrSossidge 35d37e1fe8 Add external load power calculation 2026-05-18 14:17:19 +01:00
MrSossidge 1c19d29353 Add external device load sensor 2026-05-18 13:49:59 +01:00
MrSossidge 8de1704adc Working Victron SmartSolar BLE to MQTT bridge with HA discovery 2026-05-17 20:32:53 +01:00