-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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: add unregister connection callback function #64599
Bluetooth: Host: add unregister connection callback function #64599
Conversation
537f26f
to
74dd4c3
Compare
74dd4c3
to
dfb9247
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Functionality looks good.
Some documentation should be updated, and a code style comment.
Finally, since this is adding a new function in the public API, we should test that it works as intended in CI.
* | ||
* @return Zero on success or negative error code otherwise. | ||
*/ | ||
int bt_conn_cb_unregister(struct bt_conn_cb *cb); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we should expand at least one of our tests (possibly babblesim (bsim) tests, or a unit test) to run and test this functionality.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
They added a test, could you re-review?
dfb9247
to
a802424
Compare
a802424
to
8e0869b
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Changes LGTM to me, but I do still think we should add a test of this before merging
Hello @Thalley , what should I do next? |
HI @theob-pro , |
The thing we are requesting is that is it being properly tested by CI, so that we can be sure it works for more than just the shell and that it continues to work if there are other changes. It isn't too difficult to get started on babblesim (or even unit tests), so be don't afraid to look into it :) |
@Thalley, @theob-pro can you point/guide @zhjseu to where you expect the test cases to exist in the test tree? |
I would create a new test under https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/bsim/bluetooth/host/misc that does the following:
|
@Thalley, Thanks for your reply, |
I think you should do it if you are up for it :)
I would create a new directory in https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/bsim/bluetooth/host/misc and create a new test from scratch (using e.g. https://github.com/zephyrproject-rtos/zephyr/tree/main/tests/bsim/bluetooth/host/misc/disable as inspiration). That way we can have a specific test for this.
You simply compile it as you would with any other application, but using the |
Hi @Thalley , reviewers, After setup BabbleSim environment in my local PC, compile (west build -p always -b nrf52_bsim -d xxx xxx) still failed says: Can't Windows PC be used to compile and run the app target to |
@zhaynxp yes bsim only works on linux. You can set up a virtual machine w/ ubuntu 22.04 and it should work in that environment. |
Hi @jori-nordic , thanks for the info. More one question is what if the bsim test pass on our local linux setup? any material or evidence needed to submit to this ticket for clarification? Could you please share next step? |
If the new test passes on your local setup, the next step is to add it to the pull request introducing the change. From this PR you can see what you need to add a new test. |
76dd0cc
to
5d1fa18
Compare
5d1fa18
to
234dfe7
Compare
break; | ||
} | ||
|
||
(*conn_count)++; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
since we're only creating LE connections, you could move this to L105.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
noted, resolved this, thanks a lot!
234dfe7
to
14de862
Compare
@zhaynxp seems the permissions are not set properly on the test you just made. As for the other error, the workflow used by zephyr PRs is to always force-push, and rebase on You can probably resolve that by doing a |
d207675
to
e857483
Compare
Hello @jori-nordic , all, thanks for the suggestions. After above 2 problems solved, a new error occured: |
you should add it below here:
edit: you can test that locally by running this from the zephyrproject/zephyr/ dir: $(west topdir)/zephyr/tests/bsim/bluetooth/host/compile.sh && SEARCH_PATH=$(west topdir)/zephyr/tests/bsim/bluetooth/host/misc/unregister_conn_cb $(west topdir)/zephyr/tests/bsim/run_parallel.sh |
d8b4e7c
to
8933c61
Compare
[Description] tests: shell: Restart bt will register the same connection callback twice. Callback next node point to itself, when link established callback function loop infinitely. [Fix] Unregister the previous callback to avoid register repeatedly. [Test] After bt init/disable times, create connection successfully. Signed-off-by: huajiang zheng <[email protected]>
8933c61
to
338aa9d
Compare
Hi @jori-nordic @Thalley , would you please approve this PR if no more changes are needed? |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm approving since considering the current callback struct definition, this is the only way to do it and the PR has been open for long enough without me pointing the following out: would it perhaps have made more sense to just convert the callback list to sys_slist_t
and use sys_snode_t
in the callback struct instead of a custom linked list pointer? Then we don't have to do this reimplementation of the linked list manipulation code. Anyway, can be done as a follow-up effort as far as I'm concerned.
[Description]
tests: shell: Restart bt will register the same connection callback twice.
Callback next node point to itself, when link established callback function
loop infinitely.
[Fix]
Unregister the previous callback to avoid register repeatedly.
[Test]
After bt init/disable times, create connection successfully.