Bluetooth: Extend advertising parameters with optional own address
Applications may want finer control of the NRPA used for non-connectable beacons, and provide it up-front rather than letting the stack generate one. Change-Id: I84d459372cc85ed09a8f9cde16dbb9b98dec2a43 Signed-off-by: Johan Hedberg <johan.hedberg@intel.com>
This commit is contained in:
parent
d883fcf814
commit
5ac059b6b9
2 changed files with 18 additions and 2 deletions
|
@ -126,6 +126,12 @@ struct bt_le_adv_param {
|
|||
|
||||
/** Maximum Advertising Interval (N * 0.625) */
|
||||
uint16_t interval_max;
|
||||
|
||||
/** Optional pre-defined (random) own address. Currently
|
||||
* the only permitted use of this is for NRPA with
|
||||
* non-connectable advertising.
|
||||
*/
|
||||
const bt_addr_t *own_addr;
|
||||
};
|
||||
|
||||
/** Helper to declare advertising parameters inline
|
||||
|
|
|
@ -3844,11 +3844,21 @@ int bt_le_adv_start(const struct bt_le_adv_param *param,
|
|||
#endif /* CONFIG_BLUETOOTH_PRIVACY */
|
||||
set_param->type = BT_LE_ADV_IND;
|
||||
} else {
|
||||
if (param->own_addr) {
|
||||
/* Only NRPA is allowed */
|
||||
if (!BT_ADDR_IS_NRPA(param->own_addr)) {
|
||||
return -EINVAL;
|
||||
}
|
||||
|
||||
err = set_random_address(param->own_addr);
|
||||
} else {
|
||||
#if defined(CONFIG_BLUETOOTH_PRIVACY)
|
||||
err = le_set_rpa();
|
||||
err = le_set_rpa();
|
||||
#else
|
||||
err = le_set_nrpa();
|
||||
err = le_set_nrpa();
|
||||
#endif /* CONFIG_BLUETOOTH_PRIVACY */
|
||||
}
|
||||
|
||||
if (err) {
|
||||
net_buf_unref(buf);
|
||||
return err;
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue