-
Notifications
You must be signed in to change notification settings - Fork 7.5k
Bluetooth: host: Add RPA in directed advertisement support #14984
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: Add RPA in directed advertisement support #14984
Conversation
subsys/bluetooth/host/hci_core.c
Outdated
if (IS_ENABLED(CONFIG_BT_SMP) && | ||
!IS_ENABLED(CONFIG_BT_PRIVACY) && | ||
BT_FEAT_LE_PRIVACY(bt_dev.le.features) && | ||
param->options & BT_LE_ADV_OPT_DIR_ADDR_RPA) { |
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.
put parentheses around (foo & bar) to make it clear that you didn't intend to use &&
subsys/bluetooth/host/settings.c
Outdated
#define ID_SIZE_MAX sizeof(bt_dev.irk) | ||
#else | ||
#define ID_SIZE_MAX sizeof(bt_dev.id_addr) | ||
#endif |
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 doesn't seem related, and it was actually removed by one of my own PRs recently.
Codecov Report
@@ Coverage Diff @@
## master #14984 +/- ##
==========================================
+ Coverage 52.92% 52.93% +0.01%
==========================================
Files 309 309
Lines 45268 45267 -1
Branches 10451 10451
==========================================
+ Hits 23956 23960 +4
+ Misses 16544 16542 -2
+ Partials 4768 4765 -3
Continue to review full report at Codecov.
|
b1fc94b
to
1245d12
Compare
There's something I don't understand here. The HCI spec says the following about values 0x02 and 0x03 for the 0x03 Controller generates the Resolvable Private Address based on the local IRK from the resolving list. If the resolving list contains no matching entry, use the random address from LE_Set_Advertising_Set_Random_Address. Now, as you say we don't have a local IRK, so based on the above our behaviour should be exactly the same as if 0x00 or 0x01 would have been given, right? So why do we go through the trouble to say 0x02 or 0x03 when we know the controller will fall back to just normal public/random address? Another thing that's bothering me is that it should be abundantly clear what API features are workarounds for broken devices (which seems to be the case here - please correct me if I'm wrong), however it's not at all clear from the public API additions. To me the text you've added in the API sounds like this is normal behaviour for privacy-enabled centrals. Am I misunderstanding something here? |
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.
Looks good, just doc issues
include/bluetooth/bluetooth.h
Outdated
* supports address resolution of directed advertisement. | ||
* It is the responsibility of the application to check that the remote | ||
* device supports address resolution of directed advertisements by | ||
* reading it's Central Address Resolution characteristic. |
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.
*its
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.
@joerchan this doesn't seem to be fixed yet?
include/bluetooth/bluetooth.h
Outdated
|
||
/** Enable use of Private Resolvable Address in directed advertisements | ||
* when CONFIG_BT_PRIVACY is not enabled. | ||
* This is required if the remote device is privacy enabled and |
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.
privacy-enabled
include/bluetooth/bluetooth.h
Outdated
@@ -277,6 +277,16 @@ enum { | |||
* bt_conn_create_slave_le(). | |||
*/ | |||
BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY = BIT(4), | |||
|
|||
/** Enable use of Private Resolvable Address in directed advertisements |
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.
*Resolvable Private Address (RPA)
Please specify that this only affects TargetA and not AdvA
@joerchan for the record, @carlescufi helped clarify the situation with own_addr_type and the peer_addr being linked even when we don't have a local IRK. I.e. 0x02/0x03 is not quite the same as 0x00/0x01 when we don't have an IRK ourselves. The requested clarifications by @carlescufi are helpful in this regard. |
24fe883
to
f96e87f
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 now, thanks!
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.
Besides the typo that's not yet fixed this PR is fine with me
include/bluetooth/bluetooth.h
Outdated
* supports address resolution of directed advertisement. | ||
* It is the responsibility of the application to check that the remote | ||
* device supports address resolution of directed advertisements by | ||
* reading it's Central Address Resolution characteristic. |
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.
@joerchan this doesn't seem to be fixed yet?
In order to advertise directed to a privacy enabled central the initiator field of the directed adv packet needs to set to an RPA. To instruct the controller to use an RPA in the initiator field own address type should be set to either 0x02 or 0x03. Since it is not certain that a remote device supports address resolution of the initiator address we add an option to turn this on and give the application the responsibility to check if peer supports this. Fixes zephyrproject-rtos#14743 Signed-off-by: Joakim Andersson <[email protected]>
f96e87f
to
cead2e8
Compare
In order to advertise directed to a privacy enabled central the
initiator field of the directed adv packet needs to set to an RPA.
To instruct the controller to use an RPA in the initiator field own
address type should be set to either 0x02 or 0x03.
Since it is not certain that a remote device supports address resolution
of the initiator address we add an option to turn this on and give the
application the responsibility to check if peer supports this.
Fixes #14743
Signed-off-by: Joakim Andersson [email protected]