mirror of
https://github.com/1technophile/OpenMQTTGateway.git
synced 2026-03-03 05:54:23 +01:00
* [BLE] Add BM6 Battery Monitor connection support Implement BLE connection support for BM6 Battery Monitor devices, following the BM2 pattern with BM6-specific protocol handling. Key features: - Encrypted command/response using AES-128 CBC - Read voltage, temperature, and State of Charge (SoC) - Home Assistant MQTT Discovery support - Device tracker integration Technical implementation: - Add BM6_connect class with encrypted command handling - Encryption key (static const): "leagend\xff\xfe0100009" - Parse hex string positions for voltage (15-17), temp (8-9), SoC (12-13) - Add discovery with 3 sensors (voltage, temperature, battery %) - Validate message signature (D15507) - Add canWrite() check before writing to characteristic - Empty stub for non-ESP32 builds Code quality improvements: - Extract AES key as static constant to avoid duplication - Use shared jsonVoltBM template for both BM2 and BM6 - Clean up commented-out reasoning in parsing logic Based on reverse engineering from: https://github.com/JeffWDH/bm6-battery-monitor Files modified: - main/gatewayBLEConnect.h: Add BM6_connect class - main/gatewayBLEConnect.cpp: Implement BM6 connection logic - main/gatewayBT.cpp: Add detection, connection, and discovery handlers - main/config_mqttDiscovery.h: Rename jsonVoltBM2 to jsonVoltBM Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com> * Add BM6 to exceptions --------- Co-authored-by: Florian <1technophile@users.noreply.github.com> Co-authored-by: Claude Sonnet 4.5 <noreply@anthropic.com>
33 KiB
33 KiB