-
Notifications
You must be signed in to change notification settings - Fork 8.1k
bluetooth: add macros for BT_BAP_PAST_SERVICE_DATA #95487
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
base: main
Are you sure you want to change the base?
Conversation
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.
Thankss for your contribution. Some formatting comments, but mostly requests to add users of this new macro so that we can verify that it works :)
dec4870
to
e735249
Compare
16db4b0
to
c3052f1
Compare
c3052f1
to
9280e92
Compare
@iliar please rebase on main |
9280e92
to
02a6b62
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.
I think there are a few mistakes that needs to be fixed
02a6b62
to
2f9748d
Compare
2f9748d
to
2e15b49
Compare
884d00c
to
359eaf7
Compare
This commit adds macros for packing PAST service data for BAP. Signed-off-by: Iliar Rabet <[email protected]>
359eaf7
to
670795e
Compare
|
((uint16_t)(_src_id) & 0xFFU) << 8U \ | ||
| ((uint16_t)(_past_flags) & 0xFFU) |
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.
We have a 100-line maximum in Zephy, so we could do
((uint16_t)(_src_id) & 0xFFU) << 8U \ | |
| ((uint16_t)(_past_flags) & 0xFFU) | |
((uint16_t)(_src_id) & 0xFFU) << 8U | ((uint16_t)(_past_flags) & 0xFFU) |
else I would put the |
on the first line
((uint16_t)(_src_id) & 0xFFU) << 8U \ | |
| ((uint16_t)(_past_flags) & 0xFFU) | |
((uint16_t)(_src_id) & 0xFFU) << 8U | \ | |
((uint16_t)(_past_flags) & 0xFFU) |
IS_ENABLED(CONFIG_BT_PER_ADV_SYNC_TRANSFER_SENDER)) { | ||
uint8_t past_flags = BT_BAP_PAST_FLAG_NO_MATCH_ADV_EXT_IND; | ||
|
||
bt_le_ext_adv_get_info(ext_adv, &info); |
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.
Our coding guidelines require that all functions that may return an error, shall have the return value checked, so this must be
bt_le_ext_adv_get_info(ext_adv, &info); | |
err = bt_le_ext_adv_get_info(ext_adv, &info); |
In cases like this where it should never fail unless something terribly has happened, I'd test this with an ASSERT
bt_le_ext_adv_get_info(ext_adv, &info); | |
err = bt_le_ext_adv_get_info(ext_adv, &info); | |
__ASSERT(err == 0, "Failed to get adv info: %d", err); |
This also applies to the other cases in this PR
uint8_t src_id = info.sid; | ||
|
||
|
||
err = bt_le_per_adv_sync_transfer(g_pa_sync, | ||
conn, | ||
BT_BAP_PAST_SERVICE_DATA(past_flags, src_id)); |
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.
uint8_t src_id = info.sid; | |
err = bt_le_per_adv_sync_transfer(g_pa_sync, | |
conn, | |
BT_BAP_PAST_SERVICE_DATA(past_flags, src_id)); | |
err = bt_le_per_adv_sync_transfer(g_pa_sync, | |
conn, | |
BT_BAP_PAST_SERVICE_DATA(past_flags, info.src_id)); |
bt_le_per_adv_sync_get_info(g_pa_sync, &info); | ||
uint8_t src_id = info.sid; | ||
|
||
err = bt_le_per_adv_sync_transfer(g_pa_sync, | ||
conn, | ||
BT_BAP_PAST_SERVICE_DATA(past_flags, src_id)); |
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.
bt_le_per_adv_sync_get_info(g_pa_sync, &info); | |
uint8_t src_id = info.sid; | |
err = bt_le_per_adv_sync_transfer(g_pa_sync, | |
conn, | |
BT_BAP_PAST_SERVICE_DATA(past_flags, src_id)); | |
bt_le_per_adv_sync_get_info(g_pa_sync, &info); | |
err = bt_le_per_adv_sync_transfer(g_pa_sync, | |
conn, | |
BT_BAP_PAST_SERVICE_DATA(past_flags, info.src_id)); |
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.
Thanks for feedback.
but I am getting this error:
error: ‘struct bt_le_per_adv_sync_info’ has no member named ‘src_id’
The defintion looks like this:
/** @brief Periodic advertising set info structure. */
struct bt_le_per_adv_sync_info {
/** Periodic Advertiser Address */
bt_addr_le_t addr;
/** Advertising Set Identifier, valid range @ref BT_GAP_SID_MIN to @ref BT_GAP_SID_MAX. */
uint8_t sid;
/** Periodic advertising interval (N * 1.25 ms) */
uint16_t interval;
/** Advertiser PHY (see @ref bt_gap_le_phy). */
uint8_t phy;
};
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.
Ah, this is on me. It's not the sid
that we need, but the src_id
of the receive state. bt_le_per_adv_sync_get_info
and bt_le_ext_adv_get_info
shouldn't be used for this purpose. Sorry for a bad recommendation when I suggested that :D
We need to store the src_id
of the receive state somewhere and then use that use. I confused myself with sid
, which is not the same as src_id
This commit adds macros for packing and extracting PAST service data for BAP.
Fixes #95337