8000
Skip to content

[esp32_ble_client] Reduce GATT data event logging to prevent firmware update failures - #13252

Merged
bdraco merged 1 commit into
devfrom
fix_firmware_update_failing_with_bluetooth_proxy_from_logging
Jan 16, 2026
Merged

[esp32_ble_client] Reduce GATT data event logging to prevent firmware update failures#13252
bdraco merged 1 commit into
devfrom
fix_firmware_update_failing_with_bluetooth_proxy_from_logging

Conversation

@bdraco
@bdraco bdraco commented Jan 15, 2026
Copy link
Copy Markdown
Member

What does this implement/fix?

Reduces BLE GATT event logging from DEBUG to VERBOSE level to prevent failures when updating firmware on BLE devices through Bluetooth Proxy.

When using Bluetooth Proxy to update firmware on end BLE devices (locks, sensors, etc.) or pair with them, data transfer events (notifications, reads, writes) fire rapidly. Previously these were logged at DEBUG level - a single firmware update pushed to an end device can generate 10,000+ log messages. The UART write delays from this log flood cause timing issues that make these operations fail.

Changes:

  • Renamed log_gattc_event_() to log_gattc_lifecycle_event_() for clarity
  • Added new log_gattc_data_event_() helper that logs at VERBOSE level
  • Connection lifecycle events (OPEN, CONNECT, CLOSE, SEARCH_CMPL) remain at DEBUG level
  • Data transfer events moved to VERBOSE level:
    • ESP_GATTC_READ_CHAR_EVT
    • ESP_GATTC_WRITE_CHAR_EVT
    • ESP_GATTC_NOTIFY_EVT
    • ESP_GATTC_READ_DESCR_EVT
    • ESP_GATTC_WRITE_DESCR_EVT
    • ESP_GATTC_REG_FOR_NOTIFY_EVT
    • ESP_GATTC_UNREG_FOR_NOTIFY_EVT
    • Unknown/default events

Types of changes

  • Bugfix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • Developer breaking change (an API change that could break external components)
  • Code quality improvements to existing code or addition of tests
  • Other

Related issue or feature (if applicable):

  • Improves reliability of firmware updates to end BLE devices via Bluetooth Proxy and device pairing

Pull request in esphome-docs with documentation (if applicable):

  • N/A

Test Environment

  • ESP32
  • ESP32 IDF
  • ESP8266
  • RP2040
  • BK72xx
  • RTL87xx
  • LN882x
  • nRF52840

Example entry for config.yaml:

# No configuration changes needed - this is a logging level fix
bluetooth_proxy:
  active: true

Checklist:

  • The code change is tested and works locally.
  • Tests have been added to verify that the new code works (under tests/ folder).

If user exposed functionality or configuration variables are added/changed:

Copilot AI review requested due to automatic review settings January 15, 2026 21:50
@bdraco
bdraco requested a review from jesserockz as a code owner January 15, 2026 21:50
@bdraco bdraco added this to the 2026.1.0b3 milestone Jan 15, 2026
@github-actions
Copy link
Copy Markdown
Contributor

👋 Hi there! I've automatically requested reviews from codeowners based on the files changed in this PR.

@jesserockz - You've been requested to review this PR as codeowner(s) of 2 file(s) that were modified. Thanks for your time! 🙏

@github-actions
Copy link
Copy Markdown
Contributor

To use the changes from this PR as an external component, add the following to your ESPHome configuration YAML file:

external_components:
  - source: github://pr#13252
    components: [esp32_ble_client]
    refresh: 1h

(Added by the PR bot)

@codecov-commenter
codecov-commenter commented Jan 15, 2026
Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 73.76%. Comparing base (00cc9e4) to head (0109e4b).
⚠️ Report is 12 commits behind head on dev.

Additional details and impacted files
@@            Coverage Diff             @@
##              dev   #13252      +/-   ##
==========================================
- Coverage   73.79%   73.76%   -0.03%     
==========================================
  Files          53       53              
  Lines       11329    11329              
  Branches     1538     1538              
==========================================
- Hits         8360     8357       -3     
- Misses       2570     2572       +2     
- Partials      399      400       +1     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

Copilot AI left a comment
8000 Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR addresses firmware update and pairing failures in BLE devices proxied through ESPHome by reducing logging verbosity of high-frequency data transfer events. When updating firmware or pairing with BLE devices, thousands of GATT data events can generate excessive UART output that introduces timing delays, causing operations to fail.

Changes:

  • Renamed log_gattc_event_() to log_gattc_lifecycle_event_() for connection lifecycle events that remain at DEBUG level
  • Added log_gattc_data_event_() helper that logs high-frequency data transfer events at VERBOSE level
  • Moved 7 data transfer event types (READ/WRITE operations, NOTIFY, REG/UNREG_FOR_NOTIFY) and unknown events to VERBOSE logging

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
esphome/components/esp32_ble_client/ble_client_base.h Added declaration for new log_gattc_data_event_() function and renamed log_gattc_event_() to log_gattc_lifecycle_event_()
esphome/components/esp32_ble_client/ble_client_base.cpp Implemented both logging functions with appropriate log levels, updated all GATT event handlers to use the correct function, and added comprehensive comments explaining the rationale

@github-actions
Copy link
Copy Markdown
Contributor

Memory Impact Analysis

Components: esp32_ble_client
Platform: esp32-idf

Metric Target Branch This PR Change
RAM 37,236 bytes 37,236 bytes ➡️ +0 bytes (0.00%)
Flash 656,495 bytes 656,523 bytes 📈 🔸 +28 bytes (+0.00%)
📊 Component Memory Breakdown
Component Target Flash PR Flash Change
[esphome]esp32_ble_client 2,999 bytes 3,025 bytes 📈 🔸 +26 bytes (+0.87%)
🔍 Symbol-Level Changes (click to expand)

Changed Symbols

Symbol Target Size PR Size Change
esphome::esp32_ble_client::BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t, unsigned char...esphome::esp32_ble_client::BLEClientBase::gattc_event_handler(esp_gattc_cb_event_t, unsigned char, esp_ble_gattc_cb_param_t*)
1,327 bytes 1,323 bytes 📉 -4 bytes (-0.30%)

New Symbols (top 15)

Symbol Size
esphome::esp32_ble_client::BLEClientBase::log_gattc_lifecycle_event_(char const*) 30 bytes
esphome::esp32_ble_client::BLEClientBase::log_gattc_data_event_(char const*) 30 bytes

Removed Symbols (top 15)

Symbol Size
esphome::esp32_ble_client::BLEClientBase::log_gattc_event_(char const*) 30 bytes

Note: This analysis measures static RAM and Flash usage only (compile-time allocation).
Dynamic memory (heap) cannot be measured automatically.
⚠️ You must test this PR on a real device to measure free heap and ensure no runtime memory issues.

This analysis runs automatically when components change. Memory usage is measured from a representative test configuration.

@bdraco
bdraco commented Jan 16, 2026
8000 Copy link
Copy Markdown
Member Author

thanks

@bdraco
bdraco merged commit b1230ec into dev Jan 16, 2026
42 checks passed
@bdraco
bdraco deleted the fix_firmware_update_failing_with_bluetooth_proxy_from_logging branch January 16, 2026 02:49
swoboda1337 pushed a commit that referenced this pull request Jan 17, 2026
@swoboda1337 swoboda1337 mentioned this pull request Jan 17, 2026
@github-actions github-actions Bot locked and limited conversation to collaborators Jan 18, 2026
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants

0