Skip to content
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

Bluetooth: Host: Added 'recycled' callback to bt_conn_cb #68266

Merged

Conversation

ubieda
Copy link
Member

@ubieda ubieda commented Jan 30, 2024

This PR attempts to address #68114, by:

  • Adding the recycled callback to the bt_conn_cb, which is triggered once a connection object from a previous connection has been freed by the BT stack. This trigger is applicable to both listeners subscribed over bt_conn_cb_register(), as well as statically defined with BT_CONN_CB_DEFINE().
  • Adding a babblesim testsuite that demonstrates the use of this callback to gracefully restart extended advertisement across disconnects.
  • Adding a bluetooth sample demonstrating the use of this same callback for both BT scanner and advertiser, in the same context of Extended Advertisements.

Resolves: #68114

@zephyrbot zephyrbot added Release Notes To be mentioned in the release notes area: Bluetooth area: Samples Samples area: Bluetooth Host Bluetooth Host (excluding BR/EDR) labels Jan 30, 2024
@ubieda ubieda force-pushed the feature/bt/add-conn-recycled-evt branch 2 times, most recently from ecb6338 to 1e5417d Compare January 30, 2024 06:50
@Thalley Thalley removed their request for review January 30, 2024 10:43
@alwa-nordic alwa-nordic changed the title Bluetooth: Host: Added recycled callback to bt_conn_cb Bluetooth: Host: Added 'recycled' callback to bt_conn_cb Jan 30, 2024
@ubieda ubieda force-pushed the feature/bt/add-conn-recycled-evt branch from 1e5417d to d3669a2 Compare January 30, 2024 15:15
@ubieda
Copy link
Member Author

ubieda commented Jan 30, 2024

FYI - Addressed all the observations, except the polling signals refactoring. I'll tackle that later today.

@ubieda ubieda force-pushed the feature/bt/add-conn-recycled-evt branch from d3669a2 to c50b332 Compare January 30, 2024 20:46
@ubieda
Copy link
Member Author

ubieda commented Jan 30, 2024

Update: All requested changes are made effective to the best of my knowledge

@ubieda ubieda requested a review from alwa-nordic January 30, 2024 21:26
subsys/bluetooth/host/conn.c Outdated Show resolved Hide resolved
subsys/bluetooth/host/conn.c Show resolved Hide resolved
include/zephyr/bluetooth/conn.h Show resolved Hide resolved
samples/bluetooth/extended_adv/README.rst Outdated Show resolved Hide resolved
@ubieda ubieda force-pushed the feature/bt/add-conn-recycled-evt branch from c50b332 to 0be1a84 Compare January 31, 2024 13:07
- Which allow listeners to attempt to use the freed connection object to
perform actions as e.g: start connectable advertisements.
- Refactored bt_conn_unref() so it does not access conn struct after
decrementing its reference count.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
Added on the bt_conn_cb set, used to notify listeners that a previously
allocated connection object has been freed. Used for e.g: restart
extended advertisements.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
@ubieda ubieda force-pushed the feature/bt/add-conn-recycled-evt branch from 0be1a84 to 9605415 Compare January 31, 2024 13:14
jori-nordic
jori-nordic previously approved these changes Jan 31, 2024
@ubieda
Copy link
Member Author

ubieda commented Jan 31, 2024

tests/bsim/bluetooth/host/adv/extended/tests_scripts/ext_adv_conn.sh FAILED
d_00: WARNING: (src/bs_pc_base.c:146): Previous lock file found /tmp/bs_root/ext_adv/2G4.d0.lock
d_00: WARNING: (src/bs_pc_base.c:181): Found a previous, still RUNNING process w pid 7134 with the same sim_id and device port which would interfere with this one, aborting
d_00: ERROR: (src/bs_pc_base.c:460): Failed to get lock
d_00: @00:00:00.000000 TESTCASE NOT PASSED at exit (test return (1) indicates it was still in progress)
d_01: WARNING: (src/bs_pc_base.c:146): Previous lock file found /tmp/bs_root/ext_adv/2G4.d1.lock
d_01: WARNING: (src/bs_pc_base.c:181): Found a previous, still RUNNING process w pid 7135 with the same sim_id and device port which would interfere with this one, aborting
d_01: ERROR: (src/bs_pc_base.c:460): Failed to get lock
d_01: @00:00:00.000000 TESTCASE NOT PASSED at exit (test return (1) indicates it was still in progress)
p_2G4: WARNING: (src/bs_pc_base.c:146): Previous lock file found /tmp/bs_root/ext_adv/2G4.phy.lock
p_2G4: WARNING: (src/bs_pc_base.c:181): Found a previous, still RUNNING process w pid 7136 with the same sim_id and device port which would interfere with this one, aborting

The CI workflow for babblesim tests is failing with this info. I am not able to replicate this on my local machine nor am I sure how to fix it. Could I get some more context?

Where extended advertising is restablished through the use of
recycled() callback, registers over bt_conn_cb_register().

Signed-off-by: Luis Ubieda <luisf@croxel.com>
Both advertiser and scanner demonstrate the use of extended advertising
and scanning, and how to gracefully restart the extended advertisements
through the use of recycle() callback. In the sample, the advertiser
initiates a connectable advertisement set, which prompts the scanner to
connect. After the connection is established, the advertiser waits for
5 seconds to disconnect. After the connection is dropped, the advertiser
immediately restarts broadcasting, while the scanner cools-down for
5 seconds to restart its process.

Signed-off-by: Luis Ubieda <luisf@croxel.com>
@fabiobaltieri fabiobaltieri merged commit 2745f6a into zephyrproject-rtos:main Feb 1, 2024
21 checks passed
@ubieda ubieda deleted the feature/bt/add-conn-recycled-evt branch February 1, 2024 15:21
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: Bluetooth Host Bluetooth Host (excluding BR/EDR) area: Bluetooth area: Samples Samples Release Notes To be mentioned in the release notes
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bluetooth: host: add conn-recycled event
6 participants