-
Notifications
You must be signed in to change notification settings - Fork 8.3k
Bluetooth: Host: Add conversion macros from ms to various units #81068
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
Conversation
include/zephyr/bluetooth/gap.h
Outdated
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 wasn't sure where to put these. We already have various conversion functions like BT_GAP_PER_ADV_INTERVAL_TO_MS and BT_CONN_INTERVAL_TO_MS, but they are placed here and there.
include/zephyr/bluetooth/gap.h
Outdated
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.
Wasn't sure whether to use INT or INTERVAL. We seem to be using both
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.
Personally I'd prefer INTERVAL, it is more consistent with the previous macro BT_GAP_PER_ADV_INTERVAL_TO_MS. Not going to block this because at the end of the day INT also works
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 "interval".
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.
Updated to INTERVAL
502fad3 to
4788ec6
Compare
4788ec6 to
70fa597
Compare
|
What do the reviewers think of the prefix and location of these macros? Should they be in gap and prefixed with BT_GAP like they are today, or should they be moved to the individual parts (e.g. adv => |
714e26b to
32a0db2
Compare
4bd2837 to
fff387f
Compare
|
Added unit tests |
fff387f to
491436e
Compare
tests/bluetooth/gap/src/main.c
Outdated
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.
Wasn't sure whether to use hex as expected (typical use is hex), or decimal. Let me know what you prefer
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.
hex is nice
I don't think we have too many conversion functions like this yet; anyways it is nice to have these grouped together, so I'd say keep them in gap |
491436e to
625a276
Compare
|
Added microsecond versions of the macros as well, as well as added the value ranges. Since we don't have the value ranges defined in MS/US, I opted to just add them as literal values instead of values that could be |
625a276 to
6a4da5d
Compare
Add conversion macros from milliseconds to various units. The purpose of these macros is to make it more clear/easier for users to set and read values using milliseconds rather than the various BT units which may be in 0.625, 1.25 or 10ms units. This is especially useful when comparing related values using different units, such as advertising interval (0.625ms units) and periodic advertising interval units (1.25ms units). Users will have to be aware that these macros can provide slightly different values than what is provided, if the provided values do not match the units. Signed-off-by: Emil Gydesen <[email protected]>
6a4da5d to
01d1884
Compare
Add conversion macros from milliseconds to various units. The purpose of these macros is to make it more clear/easier for users to set and read values using milliseconds rather than the various BT units which may be in 0.625, 1.25 or 10ms units.
This is especially useful when comparing related values using different units, such as advertising interval (0.625ms units) and periodic advertising interval units (1.25ms units).
Users will have to be aware that these macros can provide slightly different values than what is provided, if the provided values do not match the units.
A followup PR for audio can be found here #81093 which uses more of these macros.