-
Notifications
You must be signed in to change notification settings - Fork 6.9k
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: pacs: Add dynamic PACS registration #83730
Conversation
523edd9
to
63351e3
Compare
doc/releases/migration-guide-4.1.rst
Outdated
@@ -321,6 +321,10 @@ Bluetooth Audio | |||
* :kconfig:option:`CONFIG_BT_PAC_SNK` | |||
* :kconfig:option:`CONFIG_BT_PAC_SRC` | |||
|
|||
* PACS have been changed to support dynamic, runtime configuration. This means that PACS now has | |||
to be regsitered with :c:func:`bt_pacs_register` before it can be used. All Kconfig option still |
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.
Just some typo:
regsitered -> registered
Runetime -> Runtime
@@ -45,6 +45,18 @@ struct bt_pacs_cap { | |||
sys_snode_t _node; | |||
}; | |||
|
|||
|
|||
/** Structure for registering PACS */ | |||
struct bt_bap_pacs_register_param { |
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.
Would it make sense to also add support for registering initial values here? i.e. the initial contexts, locations and records?
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.
It could, but it could also make sense not to do it. The current content of struct bt_bap_pacs_register_param
strictly necessary to run the service, and they cannot easily be changed, in fact they would need a reregistration to change.
Contexts, locations, and records can more easily change at runtime.
I would prefer to keep it as is for now - but if you really want this change Im happy to create an issue for future change.
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.
Sure :) It makes sense to keep as is, with the caveat that the default values are invalid, so the user shall call the other functions afterwards (similar as they have to today)
756ef02
to
eebe150
Compare
* @return 0 in case of success or negative value in case of error. | ||
*/ | ||
int bt_pacs_register(const struct bt_bap_pacs_register_param *param); | ||
|
||
/** | ||
* @brief Unregister the Published Audio Capability Service instance. | ||
* | ||
* @return 0 in case of success or negative value in case of error. | ||
*/ |
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.
If possible, please use @retval
instead of @return
and specific the possible return values. It makes it easier for applications to know exactly which return values can be expected, and why
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 prefer to keep it as is, as it will forward error codes from other functions.
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 prefer to keep it as is, as it will forward error codes from other functions.
That's one of the reasons to use retval
: Simply forwarding error will make it harder to handle cases as an application.
We do not have any requirement in the coding guidelines for this, so I won't block the PR on this
tests/bsim/bluetooth/audio/src/pbp_public_broadcast_sink_test.c
Outdated
Show resolved
Hide resolved
eebe150
to
8812707
Compare
* @return 0 in case of success or negative value in case of error. | ||
*/ | ||
int bt_pacs_register(const struct bt_bap_pacs_register_param *param); | ||
|
||
/** | ||
* @brief Unregister the Published Audio Capability Service instance. | ||
* | ||
* @return 0 in case of success or negative value in case of error. | ||
*/ |
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 prefer to keep it as is, as it will forward error codes from other functions.
That's one of the reasons to use retval
: Simply forwarding error will make it harder to handle cases as an application.
We do not have any requirement in the coding guidelines for this, so I won't block the PR on this
8812707
to
972f130
Compare
a76a429
to
c9b2e77
Compare
bool snk_pac; | ||
#endif /* CONFIG_BT_PAC_SNK */ | ||
|
||
#if defined(CONFIG_BT_PAC_SNK_LOC) | ||
/** | ||
* @brief Enables or disables registration of Sink Location Characteristic. | ||
* | ||
* Registration of Sink Location is dependent on @ref bt_bap_pacs_register_param.snk_pac | ||
* also being set. | ||
*/ | ||
bool snk_loc; |
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.
Hmm, I'm starting to wonder if we should add chrc
or attr
to these names? Or prefix them with register_
?
If we ever want to expand bt_bap_pacs_register_param
to also contain default values, snk_pac
and snk_loc
are the obvious names for the default sink PAC record and sink location
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.
Don't you think we should make those name changes in such a patch where it becomes relevant then?
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.
Possibly. At least while the API is still unstable we can more easily do that, but will be much harder to do later
bba57c3
to
d48096c
Compare
Added option to set the PACS Characteristics through the bap API, making PACS configuration runtime available. Source and Sink PAC, as well as Source/Sink PAC Location is can be set through a register function in the PACS api. Signed-off-by: Fredrik Danebjer <frdn@demant.com>
d48096c
to
172fd65
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.
LGTM - should we have a before/after RAM/ROM usage check?
Would be nice if you can provide that @fredrikdanebjer :) Just so that we are aware of what I assume will be a memory increase |
Before pacs.c: Built with audio_shell using: You can find the full reports attached. |
Alright, so that's quite a significant change. I guess it's the same for the others. 400 more RAM sounds like a lot. Is it mainly the pacs_attr array? |
@Thalley Yes, pacs_attrs make up of 380 bytes. As a reference for other services we did this for: |
Added option to set the PACS Characteristics through the bap API, making PACS configuration runtime available. Source and Sink PAC, as well as Source/Sink PAC Location is can be set through a register function in the PACS api.