Bluetooth: host: Add RPA in directed advertisement support
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 <joakim.andersson@nordicsemi.no>
This commit is contained in:
parent
193fb971c2
commit
710adac50d
3 changed files with 25 additions and 3 deletions
|
@ -277,6 +277,17 @@ enum {
|
|||
* bt_conn_create_slave_le().
|
||||
*/
|
||||
BT_LE_ADV_OPT_DIR_MODE_LOW_DUTY = BIT(4),
|
||||
|
||||
/** Enable use of Resolvable Private Address (RPA) as the target address
|
||||
* in directed advertisements when CONFIG_BT_PRIVACY is not enabled.
|
||||
* This is required if the remote device is privacy-enabled and
|
||||
* supports address resolution of the target address in directed
|
||||
* advertisement.
|
||||
* It is the responsibility of the application to check that the remote
|
||||
* device supports address resolution of directed advertisements by
|
||||
* reading its Central Address Resolution characteristic.
|
||||
*/
|
||||
BT_LE_ADV_OPT_DIR_ADDR_RPA = BIT(5),
|
||||
};
|
||||
|
||||
/** LE Advertising Parameters. */
|
||||
|
|
|
@ -29,6 +29,7 @@ extern "C" {
|
|||
/* Special own address types for LL privacy (used in adv & scan parameters) */
|
||||
#define BT_HCI_OWN_ADDR_RPA_OR_PUBLIC 0x02
|
||||
#define BT_HCI_OWN_ADDR_RPA_OR_RANDOM 0x03
|
||||
#define BT_HCI_OWN_ADDR_RPA_MASK 0x02
|
||||
|
||||
/** Bluetooth Device Address */
|
||||
typedef struct {
|
||||
|
|
|
@ -3838,7 +3838,7 @@ static int le_set_event_mask(void)
|
|||
mask |= BT_EVT_MASK_LE_ADVERTISING_REPORT;
|
||||
|
||||
if (IS_ENABLED(CONFIG_BT_CONN)) {
|
||||
if (IS_ENABLED(CONFIG_BT_PRIVACY) &&
|
||||
if (IS_ENABLED(CONFIG_BT_SMP) &&
|
||||
BT_FEAT_LE_PRIVACY(bt_dev.le.features)) {
|
||||
mask |= BT_EVT_MASK_LE_ENH_CONN_COMPLETE;
|
||||
} else {
|
||||
|
@ -3982,8 +3982,7 @@ static int le_init(void)
|
|||
}
|
||||
|
||||
#if defined(CONFIG_BT_SMP)
|
||||
if (IS_ENABLED(CONFIG_BT_PRIVACY) &&
|
||||
BT_FEAT_LE_PRIVACY(bt_dev.le.features)) {
|
||||
if (BT_FEAT_LE_PRIVACY(bt_dev.le.features)) {
|
||||
struct bt_hci_rp_le_read_rl_size *rp;
|
||||
|
||||
err = bt_hci_cmd_send_sync(BT_HCI_OP_LE_READ_RL_SIZE, NULL,
|
||||
|
@ -5345,6 +5344,17 @@ int bt_le_adv_start_internal(const struct bt_le_adv_param *param,
|
|||
}
|
||||
|
||||
bt_addr_le_copy(&set_param.direct_addr, peer);
|
||||
|
||||
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)) {
|
||||
/* This will not use RPA for our own address
|
||||
* since we have set zeroed out the local IRK.
|
||||
*/
|
||||
set_param.own_addr_type |=
|
||||
BT_HCI_OWN_ADDR_RPA_MASK;
|
||||
}
|
||||
} else {
|
||||
set_param.type = BT_LE_ADV_IND;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue