-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Bluetooth: Improve ccc.cfg_changed #61170
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: Improve ccc.cfg_changed #61170
Conversation
|
could you add/extend a test for this? ie subscribing to indications, checking the CCC value on the server and then doing the same for notifications |
The doc on `_bt_gatt_ccc.value` specifies that only connected peers contribute to that value. But before this change, it was all computed from all entries in `_bt_gatt_ccc.cfg`, which include bonded but not connected peers when `CONFIG_BT_SETTINGS_CCC_LAZY_LOADING` is set. Signed-off-by: Aleksander Wasaznik <[email protected]>
Summarize the value of the CCC using bitwise-or instead of max. This is more natural and affords distinguishing between when only indications are enabled and when both notifications and indications are enabled. It is not expected that this change will affect any applications. It will not affect attributes that allow only one of notifications and indications. It will also not affect applications that only compare this value to zero. But it simplifies the interface of `_bt_gatt_ccc.value` and `_bt_gatt_ccc.cfg_changed`. Signed-off-by: Aleksander Wasaznik <[email protected]>
This documents the behavior and a suggested use case. Signed-off-by: Aleksander Wasaznik <[email protected]>
5fc8c4f to
dceb291
Compare
| break; | ||
| } | ||
|
|
||
| __ASSERT_NO_MSG(!err); |
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 ASSERTS can be disabled via Kconfig, wouldn't it be better to use regular ifs?
| __ASSERT_NO_MSG(!err); | ||
|
|
||
| while (bt_eatt_count(conn) == 0) { | ||
| LOG_DBG("E.."); |
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.
Is this DBG intended?
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 it is a good idea with some common testlib functionality. Is this something that we can perhaps apply to multiple tests, rather than keep in this single test case, or do the tests differ too much to be able to use a common testlib?
| } | ||
| k_condvar_signal(&g_ctx->done); |
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.
| } | |
| k_condvar_signal(&g_ctx->done); | |
| } | |
| k_condvar_signal(&g_ctx->done); |
|
|
||
| int bt_testlib_adv_conn(struct bt_conn **conn, int id, uint32_t adv_options) | ||
| { | ||
| int api_err; |
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.
Is it necessary to prefix this with api?
| int api_err; | |
| int err; |
| api_err = bt_gatt_read(ctx->conn, &ctx->params); | ||
|
|
||
| if (!api_err) { |
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.
| api_err = bt_gatt_read(ctx->conn, &ctx->params); | |
| if (!api_err) { | |
| api_err = bt_gatt_read(ctx->conn, &ctx->params); | |
| if (!api_err) { |
| .params = {.by_uuid = {.uuid = type, | ||
| .start_handle = start_handle, | ||
| .end_handle = end_handle}, | ||
| IF_ENABLED(CONFIG_BT_EATT, (.chan_opt = bearer))}, |
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.
This looks like it could be indented differently to be more readable. If using clang-format, try adding , after the last element
| .params = {.handle_count = 1, | ||
| .single = {.handle = handle, .offset = offset}, | ||
| IF_ENABLED(CONFIG_BT_EATT, (.chan_opt = bearer))}, |
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.
Ditto
| api_err = bt_conn_le_create(peer, BT_CONN_LE_CREATE_CONN, BT_LE_CONN_PARAM_DEFAULT, conn); | ||
|
|
||
| if (!api_err) { |
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.
| api_err = bt_conn_le_create(peer, BT_CONN_LE_CREATE_CONN, BT_LE_CONN_PARAM_DEFAULT, conn); | |
| if (!api_err) { | |
| api_err = bt_conn_le_create(peer, BT_CONN_LE_CREATE_CONN, BT_LE_CONN_PARAM_DEFAULT, conn); | |
| if (!api_err) { |
| { | ||
| int api_err; | ||
| struct bt_scan_find_name_closure ctx = { | ||
| .wanted_name = name, |
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.
The simple pointer assignment assignment here indicates that name shall have a long life time (at least until the device is found), but that isn't really that obvious from the header file. Suggest to either do a copy, or to somehow indicate in the header file that the name argument cannot just be stack allocated.
|
This pull request has been marked as stale because it has been open (more than) 60 days with no activity. Remove the stale label or add a comment saying that you would like to have the label removed otherwise this pull request will automatically be closed in 14 days. Note, that you can always re-open a closed pull request at any time. |
In this PR we improve
_bt_gatt_ccc.valueto use a more natural definition: bitwise-or instead of max. We ensure that only currently connected peers affect this value, so that the definitions stays independent of the CCC lazy loading kconfig. We document the use case for_bt_gatt_ccc.valueand clarify the documentation ofcfg_changed.Fixes: #61260
Resolves: #55373