From 4c097a576de06a567d631fe0437f76abfe14a545 Mon Sep 17 00:00:00 2001 From: Hendrik Groove Date: Sun, 14 Sep 2025 23:00:01 +0200 Subject: [PATCH] truma_inetbox: enhance device discovery with targeted queries and logging --- components/truma_inetbox/TrumaiNetBoxApp.cpp | 35 ++++++++++++-------- 1 file changed, 22 insertions(+), 13 deletions(-) diff --git a/components/truma_inetbox/TrumaiNetBoxApp.cpp b/components/truma_inetbox/TrumaiNetBoxApp.cpp index 82fbdb7..8b1ffe2 100644 --- a/components/truma_inetbox/TrumaiNetBoxApp.cpp +++ b/components/truma_inetbox/TrumaiNetBoxApp.cpp @@ -480,22 +480,31 @@ void TrumaiNetBoxApp::trigger_discovery() { return; } - // Start targeted device discovery like CP Plus does - // Query known Truma device identifiers instead of full scan + ESP_LOGI(TAG, "=== ENHANCED DISCOVERY SEQUENCE STARTED ==="); - // Query identifier 0x23 - typical for Truma heaters - std::vector heater_query = {0xB2, 0x23, 0x17, 0x46, 0x01, 0x03}; - this->master_send_diag_single(0x7F, heater_query); + // Try multiple NAD addresses - broadcast and specific + std::vector nad_addresses = {0x7F, 0x00, 0x01, 0x02, 0x03, 0x04, 0x05}; - // Query identifier 0x00 - LIN Product Identification - std::vector prod_id_query = {0xB2, 0x00, 0x17, 0x46, 0x00, 0x1F}; - this->master_send_diag_single(0x7F, prod_id_query); + for (uint8_t nad : nad_addresses) { + ESP_LOGI(TAG, "Trying NAD 0x%02X:", nad); + + // 1. Query identifier 0x23 - from CP Plus log analysis + std::vector heater_23_query = {0xB2, 0x23, 0x17, 0x46, 0x01, 0x03}; + this->master_send_diag_single(nad, heater_23_query); + ESP_LOGD(TAG, " -> Sent B2 23 query to NAD 0x%02X", nad); + + // 2. Query identifier 0x00 with heater signature (17 46 40 03) + std::vector heater_00_query = {0xB2, 0x00, 0x17, 0x46, 0x40, 0x03}; + this->master_send_diag_single(nad, heater_00_query); + ESP_LOGD(TAG, " -> Sent B2 00 heater sig query to NAD 0x%02X", nad); + + // 3. Query identifier 0x00 with CP Plus signature (as reference) + std::vector cpplus_00_query = {0xB2, 0x00, 0x17, 0x46, 0x00, 0x04}; + this->master_send_diag_single(nad, cpplus_00_query); + ESP_LOGD(TAG, " -> Sent B2 00 CP Plus sig query to NAD 0x%02X", nad); + } - // Query identifier 0x00 with different device signatures - std::vector heater_prod_query = {0xB2, 0x00, 0x17, 0x46, 0x40, 0x03}; // Heater signature - this->master_send_diag_single(0x7F, heater_prod_query); - - ESP_LOGI(TAG, "Manual discovery triggered - sending CP Plus style discovery commands"); + ESP_LOGI(TAG, "=== DISCOVERY SEQUENCE COMPLETED - Monitor PID 3D for responses ==="); } } }