Skip to content

Add method for cancelling peripheral connections #6584

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

Closed
wants to merge 2 commits into from

Conversation

jonathanhogg
Copy link
Contributor

Add a new gap_connect_cancel() method to allow an in-progress gap_connect() to be cancelled. This allows for timing-out a stuck connection attempt – typical of unreliable links or devices that suddenly disappear.

Tested on the ESP32 nimble port, but untested on btstack.

Copy link
Member

@jimmo jimmo left a comment

Choose a reason for hiding this comment

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

Thanks @jonathanhogg, this looks useful. I will test this on STM32 btstack+nimble and update.

@jimmo
Copy link
Member

jimmo commented Nov 4, 2020

Maybe just one thought... instead of adding a new method, would ble.gap_connect(None) be sufficient? (Just to save a few tens of bytes...)

@jonathanhogg
Copy link
Contributor Author

Hey @jimmo, good call! Yes, using ble.gap_connect(None) would likely match the existing API more closely. I'll hammer in that change.

Interestingly, this doesn't fix my problem anyway. It turns out that the stuck connections I am suffering from are actually a result of missing events from the BLE IRQ callback. I'm about to raise an issue to capture thoughts.

@jonathanhogg jonathanhogg force-pushed the gap_conn_cancel branch 2 times, most recently from b12a513 to ac9fb84 Compare June 11, 2021 12:34
@jonathanhogg jonathanhogg requested a review from jimmo June 12, 2021 12:41
@codecov-commenter
Copy link

Codecov Report

Merging #6584 (419ed8d) into master (0613d3e) will decrease coverage by 0.00%.
The diff coverage is n/a.

Impacted file tree graph

@@            Coverage Diff             @@
##           master    #6584      +/-   ##
==========================================
- Coverage   98.28%   98.27%   -0.01%     
==========================================
  Files         154      154              
  Lines       19988    19988              
==========================================
- Hits        19645    19644       -1     
- Misses        343      344       +1     
Impacted Files Coverage Δ
py/objlist.c 99.22% <0.00%> (-0.39%) ⬇️
py/obj.c 96.42% <0.00%> (ø)

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 0613d3e...419ed8d. Read the comment docs.

Copy link
Member

@jimmo jimmo left a comment

Choose a reason for hiding this comment

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

Other than the error message this looks good to me. Thanks @jonathanhogg !

Allow cancellation of in-progress peripheral connections.
Document new `gap_connect(None)` mechanism for cancelling an in-progress 
connection attempt.
@dpgeorge dpgeorge added the extmod Relates to extmod/ directory in source label Nov 30, 2021
@dpgeorge
Copy link
Member

dpgeorge commented Dec 1, 2021

Thanks for this, now merged in 851ecb2

@dpgeorge dpgeorge closed this Dec 1, 2021
@jonathanhogg jonathanhogg deleted the gap_conn_cancel branch December 2, 2021 11:55
tannewt added a commit to tannewt/circuitpython that referenced this pull request Jul 13, 2022
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.

4 participants