Performance Improvements, Auto-Disconnect+Polling, Bugfix.#52
Open
henfri wants to merge 11 commits into
Open
Conversation
|
thank you for this work. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
This PR contains three categories of improvements:
Key Improvements:
Bypasses passive scanning and utilizes 5ms local GATT caching. This drops the connection latency from ~4.5s down to ~1.4s on average, making the lock feel incredibly responsive.
More details on this below.
disconnect_timeout(default10s) andstatus_update_interval(default2h) to the component. The lock will automatically disconnect to save battery and will poll in the background without needing external YAMLsntpcron jobs.Details on Performance improvements.
By optimizing the BLE connection pipeline (bypassing MTU exchange, implementing local GATT caching, initiating direct connection, and introducing an idle-timeout hysteresis with automatic cache recovery), we reduced the total latency from triggering the command in Home Assistant to the physical motor starting from ~3.14 seconds to ~1.97 seconds (~37% faster).
Key Improvements & Features
1,1. MTU Negotiation Bypass
1.2. Class-Level & NVS GATT Handle Caching
1.3. Direct-Connect Scan Bypass
connect()sequence to the target MAC address.1.4. 10-Second Idle Timeout Hysteresis (Hold Connection)
1.5. Automatic GATT-Cache Recovery Fallback
Case 0x03nonce exchange) completes, the component automatically invalidates and clears the cached handles.Performance Timings Comparison
These Tests are conducted with the help of the newly implmemented run_test function.
Below is a chronological breakdown of the latency optimizations compared to the benchmarks:
Footnotes:
12:51:14, BLE connected and command sent at12:51:16, status updated to UNLOCKED and disconnected at12:51:20. Total time to motor start is estimated at ~2.5s.Configuration Setup
ESPHome SDK Configuration
To enable persistent GATT caching across ESP32 reboots, ensure your
sdkconfig_optionsinside the YAML contains the following:The attached file includes the Benchmarks.
walkthrough.md