-
Notifications
You must be signed in to change notification settings - Fork 6.5k
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: smp: Add bondable flag overlay per connection #59992
bluetooth: host: smp: Add bondable flag overlay per connection #59992
Conversation
CC: @kapi-no @MarekPieta |
043e23c
to
3579360
Compare
include/zephyr/bluetooth/conn.h
Outdated
* If the bonding flag is not overlaid, the value will depend on | ||
* BT_BONDABLE Kconfig setting. |
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.
...depend on global configuration which is set using bt_set_bondable
.
The default value of the global configuration is defined using CONFIG_BT_BONDABLE
Kconfig option.
subsys/bluetooth/host/smp.c
Outdated
@@ -288,6 +291,11 @@ static K_SEM_DEFINE(sc_local_pkey_ready, 0, 1); | |||
*/ | |||
#define BT_SMP_AUTH_CB_UNINITIALIZED ((atomic_ptr_val_t)bt_smp_pool) | |||
|
|||
/* Value used to mark that bondable flag is not initialized. |
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.
per-connection bondable flag?
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.
Looking good (apart from small doc improvements suggested by @MarekPieta)
The naming convention and the implementation for this new |
3579360
to
bd45dc0
Compare
Adressed @MarekPieta comments. |
include/zephyr/bluetooth/conn.h
Outdated
* @param conn Connection object. | ||
* @param enable Value allowing/disallowing to be bondable. | ||
*/ | ||
int bt_bondable_overlay(struct bt_conn *conn, bool enable); |
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 feel like bt_conn_set_bondable()
would be the more appropriate name. I know we have bt_smp_auth_cb_overlay()
as an internal API, but public APIs operating on a struct bt_conn *
should preferably be prefixed with bt_conn_
.
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.
Agreed, name changed.
bd45dc0
to
d0a505a
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.
could you add a bsim test checking the new functionality?
and also mark this new API as experimental (in case we later find some better way to achieve the same thing)
d0a505a
to
863cf07
Compare
863cf07
to
c70b8cb
Compare
Marked as experimental + added bsim test as per @jori-nordic request. |
subsys/bluetooth/host/Kconfig
Outdated
Enable support for setting/clearing the bonding flag on a | ||
per-connection basis. |
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.
Enable support for setting/clearing the bonding flag on a | |
per-connection basis. | |
Enable support for the bt_conn_set_bondable API function that is | |
used to set/clear the bonding flag on a per-connection basis. |
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.
Change in host looks good
|
||
SET_FLAG(flag_is_connected); | ||
|
||
if (bt_conn_set_bondable(conn, bondable)) { |
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.
could you add another round of bonding without calling bt_conn_set_bondable
?
like have a bondable by default device, try bonding and see that it works and then continue with the two test rounds you already have.
This is to check the default way of bonding is not broken.
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.
Added such case.
c70b8cb
to
30b967f
Compare
The current API for changing the bondable mode uses the global flag. With Zephyr support for multiple Bluetooth identities, the API for changing the bondable mode should be more fine-grained. The bondable requirements of one identity should not have an impact on another identity which can have a different set of requirements. This change introduces function to overlay bondable flag per connection. Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
Added test for the bt_conn_set_bondable API function. Check if we can pair without setting the bonding flag on the per-connection basis if the device was already bonded on the other identity. Signed-off-by: Mateusz Kapala <mateusz.kapala@nordicsemi.no>
30b967f
to
f9d86b5
Compare
@jhedberg would you mind taking another look? |
The current API for changing the bondable mode uses the global flag. With Zephyr support for multiple Bluetooth identities, the API for changing the bondable mode should be more fine-grained. The bondable requirements of one identity should not have an impact on another identity which can have a different set of requirements. This change introduces function to overlay bondable flag per connection.
Fixes: #57070