8000 extmod/nimble: Add timeout to deinit. by andrewleech · Pull Request #17247 · micropython/micropython · GitHub
[go: up one dir, main page]

Skip to content

extmod/nimble: Add timeout to deinit. #17247

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Jun 3, 2025

Conversation

andrewleech
Copy link
Contributor

Summary

If the BLE radio stops responding before deinit is called the function can get stuck waiting for an event that is never received, particularly if the radio is external or on a separate core.

This PR adds a timeout, similar to the timeout already used in the init function. That init function timeout was also
simplified as part of this change.

Relates to #17246

Testing

This has been tested on a stm32wb55 where the deinit was intermittently locking up waiting for the state to change.
This happened on a semi-regular basis on an application automated test suite which was running through hundreds of cycles over a number of hours.

Trade-offs and Alternatives

The main alternative to this is relying on watchdog to break the unit out of the infinite C loop once the failure occurs, but this is not appropriate for all applications.

Copy link
codecov bot commented May 5, 2025

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 98.54%. Comparing base (ba92063) to head (d5f2fc2).
Report is 4 commits behind head on master.

Additional details and impacted files
@@           Coverage Diff           @@
##           master   #17247   +/-   ##
=======================================
  Coverage   98.54%   98.54%           
=======================================
  Files         169      169           
  Lines       21898    21898           
=======================================
  Hits        21579    21579           
  Misses        319      319           

☔ 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.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Copy link
github-actions bot commented May 5, 2025

Code size report:

   bare-arm:    +0 +0.000% 
minimal x86:    +0 +0.000% 
   unix x64:    +0 +0.000% standard
      stm32:    +0 +0.000% PYBV10
     mimxrt:    +0 +0.000% TEENSY40
        rp2:    +8 +0.001% RPI_PICO_W
       samd:    +0 +0.000% ADAFRUIT_ITSYBITSY_M4_EXPRESS
  qemu rv32:    +0 +0.000% VIRT_RV32

@dpgeorge dpgeorge added the extmod Relates to extmod/ directory in source label May 6, 2025
@andrewleech
Copy link
Contributor Author

Should extend this to more closely match the init functionality with regard to raising exceptions on failure

@andrewleech andrewleech force-pushed the nimble_deinit_timeout branch 3 times, most recently from d33dd07 to 5ddd3d2 Compare May 7, 2025 00:05
@andrewleech andrewleech force-pushed the nimble_deinit_timeout branch 2 times, most recently from 3a4c672 to b343d5b Compare May 21, 2025 12:09
If the BLE radio stops responding before deinit is called the function can
get stuck waiting for an event that is never received, particularly if the
radio is external or on a separate core.

This commit adds a timeout, similar to the timeout already used in the init
function.  Updated for nimble, btstack, esp32 and zephyr bindings.

Signed-off-by: Andrew Leech <andrew.leech@planetinnovation.com.au>
@dpgeorge dpgeorge force-pushed the nimble_deinit_timeout branch from b343d5b to d5f2fc2 Compare June 3, 2025 16:23
@dpgeorge dpgeorge merged commit d5f2fc2 into micropython:master Jun 3, 2025
59 of 63 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
extmod Relates to extmod/ directory in source
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
0