From fd9d4aed5cd6ecdb4ac1a6a24d0c69024d7437c6 Mon Sep 17 00:00:00 2001 From: Michele Bigi Date: Sat, 15 Aug 2026 23:02:48 +0200 Subject: [PATCH] Fix BT1035 boot regression: drop redundant software AT+RESET, widen boot-banner listen window Redundant AT+RESET sent right after the hardware RESET# pulse could interrupt the module mid bring-up; boot-banner probe window (1500ms) was too short for the real +VER banner (~5s), causing spurious "AT init failed". 5/5 clean boots after fix vs ~1/13 before. Co-Authored-By: Claude Sonnet 5 --- .../drivers/bt1035/src/Bt1035Driver.cpp | 25 +++++++++++++------ 1 file changed, 17 insertions(+), 8 deletions(-) diff --git a/Software/components/drivers/bt1035/src/Bt1035Driver.cpp b/Software/components/drivers/bt1035/src/Bt1035Driver.cpp index 285dd76..208cf90 100644 --- a/Software/components/drivers/bt1035/src/Bt1035Driver.cpp +++ b/Software/components/drivers/bt1035/src/Bt1035Driver.cpp @@ -49,6 +49,22 @@ void flushUartRx(int uartPort) noexcept } } +// Diagnostic only: some BT1035 firmware prints an unsolicited boot banner on +// UART right after the hardware RESET# pulse. Capturing it (or its absence) +// tells us whether the UART link is electrically alive independent of the +// AT command layer. +void logRawUartBoot(int uartPort) noexcept +{ + std::array buf{}; + const int n = uart_read_bytes(static_cast(uartPort), buf.data(), + buf.size(), pdMS_TO_TICKS(3500)); + if (n <= 0) { + ESP_LOGW("Bt1035", "no spontaneous UART bytes after hardware reset"); + return; + } + ESP_LOG_BUFFER_HEX("Bt1035", buf.data(), static_cast(n)); +} + constexpr int kBrEdrScanTimeoutMs = 90000; constexpr int kScanProgressLogMs = 5000; constexpr int kScanIdleCompleteMs = 4000; @@ -945,17 +961,10 @@ std::expected Bt1035Driver::boot() uartInstalled_ = true; } + logRawUartBoot(uartPort_); uart_flush_input(static_cast(uartPort_)); vTaskDelay(pdMS_TO_TICKS(kPostUartMs)); - // Best-effort: not gated on OK — some Feasycom firmware acks before - // rebooting, some resets silently. Either way, settle and flush before - // the mandatory init sequence below, which IS gated. - (void)transmitAndExpectOk(core::buildBt1035AtLine(core::Bt1035AtCommand::Reset)); - vTaskDelay(pdMS_TO_TICKS(kPostResetMs)); - uart_flush_input(static_cast(uartPort_)); - ESP_LOGI(kTag, "AT+RESET sent"); - if (auto init = runInitSequence(); !init) { ESP_LOGE(kTag, "AT init failed"); return init;