[BT] Default BLE AES key empty, skip decryption without a key (#2310)

* [BT] Default BLE AES key empty, skip decryption without a key

Shipping a non-empty default key caused fresh installs to attempt
decryption of every encrypted PVVX/BTHome v2/Victron advertisement with
the placeholder string from User_config.h. Frames that didn't happen to
share that key were silently dropped at the CCM auth step, masking
otherwise-decodable devices (notably Victron MPPT) until users found and
entered a per-MAC key.

Initialise ble_aes[] to "" and treat an empty default as "no default
configured" in the decryption path - mirroring Theengs Gateway, which
has no default and skips frames whose MAC has no bindkey. Per-MAC keys
in ble_aes_keys still take precedence; the BLE_AES macro remains as the
WebUI placeholder hint.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [BT] clang-format: move BLE_AES default comment above #define

clang-format-9 rejected the trailing-comment continuation on the empty
BLE_AES default line. Move the explanation to a leading // block above
the #ifndef so the directive line is comment-free.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

* [BT] Use THEENGS_LOG_TRACE for missing-AES-key skip log

Previous commit referenced THEENGS_LOG_DEBUG, which OMG does not define
(only VERBOSE/TRACE/NOTICE/WARNING/ERROR exist), breaking every BLE
firmware build. Switch to THEENGS_LOG_TRACE — same level as the adjacent
"Custom AES key" / "Default AES key" trace lines.

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>

---------

Co-authored-by: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
This commit is contained in:
FlorianandClaude Opus 4.7 authored and GitHub committed 2026-05-16 10:26:49 -05:00
1 parent 647e437382
commit 319c05af5c
4 files changed
+14 -4

No files matched your search

+1 -2
View File
@@ -294,8 +294,7 @@ const char config_ble_body_decoder[] =
const char config_ble_body_encrypt[] =
"<hr><p><b>Encryption</b></p>"
"<p><b>BLE AES Default Key (32 char hex)</b></p>"
"<input id='bk' name='bk' minlength='32' maxlength='32' placeholder=" BLE_AES
" value='%s'>"
"<input id='bk' name='bk' minlength='32' maxlength='32' placeholder='00112233445566778899001122334455' value='%s'>"
"<hr><p><b>BLE Key Pairs</b></p>"
"<p>MacAddress:AESKey with space separator</p>"
"<p><textarea id='kp' name='kp' placeholder='A4C138012345:00112233445566778899001122334455' rows='3' cols='46'>%s</textarea></p>";