From 39a89c816ca9c49fd3c91a1db9c385e4869db01c Mon Sep 17 00:00:00 2001 From: Scott Penrose Date: Sat, 28 Feb 2026 14:38:30 +1100 Subject: [PATCH] Versions v0.4 ready for release --- .claude/CLAUDE.md | 54 ++++++++++++++++++++++++++++++++++++++++++++++ VERSIONS | 53 +++++++++++++++++++++++++++++++++++++++++++++ library.json | 12 ++++++++++- library.properties | 2 +- 4 files changed, 119 insertions(+), 2 deletions(-) diff --git a/.claude/CLAUDE.md b/.claude/CLAUDE.md index c8b67b3..7f68f5f 100644 --- a/.claude/CLAUDE.md +++ b/.claude/CLAUDE.md @@ -198,3 +198,57 @@ a843eb9 Keep v0.3.1 - examples/Receiver/src/main.cpp - examples/Repeater/src/main.cpp + +### Session: 2026-02-28 14:32 +**Commits:** +``` +4944757 Fix to be non blocking without tasks +31765c7 Update notes +84d153c Single callback version - vastly simplified. +``` +**Modified files:** +- examples/Logger/src/main.cpp +- examples/MultiDevice/src/main.cpp +- examples/Repeater/src/main.cpp +- library.json +- library.properties +- src/VictronBLE.cpp +- src/VictronBLE.h + + +### Session: 2026-02-28 14:33 +**Commits:** +``` +4944757 Fix to be non blocking without tasks +31765c7 Update notes +84d153c Single callback version - vastly simplified. +``` +**Modified files:** +- .claude/CLAUDE.md +- VERSIONS +- examples/Logger/src/main.cpp +- examples/MultiDevice/src/main.cpp +- examples/Repeater/src/main.cpp +- library.json +- library.properties +- src/VictronBLE.cpp +- src/VictronBLE.h + + +### Session: 2026-02-28 14:36 +**Commits:** +``` +4944757 Fix to be non blocking without tasks +31765c7 Update notes +``` +**Modified files:** +- .claude/CLAUDE.md +- VERSIONS +- examples/Logger/src/main.cpp +- examples/MultiDevice/src/main.cpp +- examples/Repeater/src/main.cpp +- library.json +- library.properties +- src/VictronBLE.cpp +- src/VictronBLE.h + diff --git a/VERSIONS b/VERSIONS index 75af240..a95b39e 100644 --- a/VERSIONS +++ b/VERSIONS @@ -1,5 +1,58 @@ # Version History +## 0.4.1 (2026-02-28) + +Major rework of library internals. Breaking API change — not backwards compatible with 0.3.x. + +### Callback API rewrite +- Replaced virtual callback class (`VictronDeviceCallback` with 4 override methods) with a + single function pointer (`VictronCallback`). Users now provide a plain function instead of + subclassing. The callback receives a `VictronDevice*` and switches on `deviceType` to access + the appropriate data via a tagged union. + +### Non-blocking BLE scanning +- `loop()` is now non-blocking — returns immediately if a scan is already running. + Previously it blocked for the entire scan duration (default 5 seconds). +- Scan restarts automatically when it completes. + +### Callback throttling +- Nonce-based deduplication: skips decrypt/parse/callback when the device's data hasn't + changed (detected via the nonce field in the BLE advertisement header). +- Configurable minimum interval (`setMinInterval()`, default 1000ms) limits callback + frequency even when data is changing rapidly. +- Encryption key byte check before AES decryption for early rejection of mismatched keys. + +### Memory and code reduction +- Replaced `std::map` with a fixed array (max 8 devices, linear search). + Eliminates heap allocation for device storage. +- Replaced Arduino `String` with fixed `char[]` arrays throughout (MAC: 12 chars, name: 32 chars). + Eliminates heap fragmentation from dynamic string operations. +- Replaced inheritance hierarchy (`VictronDeviceData` base + 4 derived classes) with a flat + `VictronDevice` struct using a tagged union. No more `new`/`delete` for device data. +- Removed `std::map` and `std::vector` includes entirely. +- Source reduced from ~970 lines to ~510 lines (48% reduction). +- Flash savings: ~11-14 KB across examples. + +### Bug fixes +- Fixed undefined behavior: derived objects were deleted through a base pointer without a + virtual destructor. Now uses flat structs, no polymorphic delete. +- Removed incorrect `panelVoltage` calculation (was dividing PV power by battery current, + which is wrong for MPPT chargers). The BLE protocol does not transmit PV voltage. +- Removed spurious `nullPad` byte from manufacturer data struct. +- Device type is now auto-detected from the BLE advertisement record type. The type + parameter in `addDevice()` is optional. + +### Removed features (commented out in header for reference) +- `VictronDeviceConfig` struct — use `addDevice(name, mac, key, type)` directly +- Per-type getter methods (`getSolarChargerData()`, etc.) — use callback instead +- `removeDevice()`, `getDevicesByType()`, `getLastError()` + +### Examples updated +- All examples updated for new callback API +- Removed `panelVoltage` from ESPNow packet structs (Repeater, FakeRepeater, Receiver) +- Removed unnecessary `delay(100)` from loop functions +- Added ESPNow Repeater and Receiver examples + ## 0.3.1 (2026-02-11) ### Changes diff --git a/library.json b/library.json index 646951f..7468985 100644 --- a/library.json +++ b/library.json @@ -1,6 +1,6 @@ { "name": "victronble", - "version": "0.3.1", + "version": "0.4.1", "description": "ESP32 library for reading Victron Energy device data via Bluetooth Low Energy (BLE) advertisements. Supports SmartSolar MPPT, SmartShunt, BMV, MultiPlus, Orion and other Victron devices.", "keywords": "victron, ble, bluetooth, solar, mppt, battery, smartshunt, smartsolar, bmv, inverter, multiplus, esp32, iot, energy, monitoring", "repository": { @@ -36,6 +36,16 @@ "name": "Repeater", "base": "examples/Repeater", "files": ["src/main.cpp"] + }, + { + "name": "Receiver", + "base": "examples/Receiver", + "files": ["src/main.cpp"] + }, + { + "name": "FakeRepeater", + "base": "examples/FakeRepeater", + "files": ["src/main.cpp"] } ], "export": { diff --git a/library.properties b/library.properties index 71d50b6..a63f3ba 100644 --- a/library.properties +++ b/library.properties @@ -1,5 +1,5 @@ name=VictronBLE -version=0.3.1 +version=0.4.1 author=Scott Penrose maintainer=Scott Penrose sentence=ESP32 library for reading Victron Energy device data via BLE for any ESP32