Skip to content

Commit de6651f

Browse files
cvinayaknordicjm
authored andcommitted
[nrf fromtree] Bluetooth: Host: Remove nested allocation of HCI command buffer
Remove nested allocation of HCI command buffer so that one less HCI command buffer is needed starting extended advertising with privacy enabled. Signed-off-by: Vinayak Kariappa Chettimada <[email protected]> (cherry picked from commit cc1b534)
1 parent 48be134 commit de6651f

File tree

1 file changed

+20
-18
lines changed
  • subsys/bluetooth/host

1 file changed

+20
-18
lines changed

subsys/bluetooth/host/adv.c

Lines changed: 20 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1127,10 +1127,25 @@ static int le_ext_adv_param_set(struct bt_le_ext_adv *adv,
11271127
uint16_t size;
11281128
bool dir_adv = param->peer != NULL, scannable;
11291129
struct net_buf *buf, *rsp;
1130+
uint8_t own_addr_type;
11301131
int err;
11311132
enum adv_name_type name_type;
11321133
uint16_t props = 0;
11331134

1135+
adv->options = param->options;
1136+
1137+
err = bt_id_set_adv_own_addr(adv, param->options, dir_adv,
1138+
&own_addr_type);
1139+
if (err) {
1140+
return err;
1141+
}
1142+
1143+
if (dir_adv) {
1144+
bt_addr_le_copy(&adv->target_addr, param->peer);
1145+
} else {
1146+
bt_addr_le_copy(&adv->target_addr, BT_ADDR_LE_ANY);
1147+
}
1148+
11341149
if (IS_ENABLED(CONFIG_BT_EXT_ADV_CODING_SELECTION) &&
11351150
BT_FEAT_LE_ADV_CODING_SEL(bt_dev.le.features)) {
11361151
opcode = BT_HCI_OP_LE_SET_EXT_ADV_PARAM_V2;
@@ -1148,31 +1163,15 @@ static int le_ext_adv_param_set(struct bt_le_ext_adv *adv,
11481163
cp = net_buf_add(buf, size);
11491164
(void)memset(cp, 0, size);
11501165

1151-
adv->options = param->options;
1152-
1153-
err = bt_id_set_adv_own_addr(adv, param->options, dir_adv,
1154-
&cp->own_addr_type);
1155-
if (err) {
1156-
net_buf_unref(buf);
1157-
return err;
1158-
}
1159-
1160-
if (dir_adv) {
1161-
bt_addr_le_copy(&adv->target_addr, param->peer);
1162-
} else {
1163-
bt_addr_le_copy(&adv->target_addr, BT_ADDR_LE_ANY);
1164-
}
1165-
1166-
name_type = get_adv_name_type_param(param);
1167-
11681166
cp->handle = adv->handle;
11691167
sys_put_le24(param->interval_min, cp->prim_min_interval);
11701168
sys_put_le24(param->interval_max, cp->prim_max_interval);
11711169
cp->prim_channel_map = get_adv_channel_map(param->options);
1170+
cp->own_addr_type = own_addr_type;
11721171
cp->filter_policy = get_filter_policy(param->options);
11731172
cp->tx_power = BT_HCI_LE_ADV_TX_POWER_NO_PREF;
1174-
11751173
cp->prim_adv_phy = BT_HCI_LE_PHY_1M;
1174+
11761175
if ((param->options & BT_LE_ADV_OPT_EXT_ADV) &&
11771176
!(param->options & BT_LE_ADV_OPT_NO_2M)) {
11781177
cp->sec_adv_phy = BT_HCI_LE_PHY_2M;
@@ -1229,6 +1228,8 @@ static int le_ext_adv_param_set(struct bt_le_ext_adv *adv,
12291228
}
12301229
}
12311230

1231+
name_type = get_adv_name_type_param(param);
1232+
12321233
if ((param->options & BT_LE_ADV_OPT_SCANNABLE) || has_scan_data ||
12331234
(name_type == ADV_NAME_TYPE_SD)) {
12341235
props |= BT_HCI_LE_ADV_PROP_SCAN;
@@ -1250,6 +1251,7 @@ static int le_ext_adv_param_set(struct bt_le_ext_adv *adv,
12501251
cp->sec_adv_max_skip = param->secondary_max_skip;
12511252

12521253
cp->props = sys_cpu_to_le16(props);
1254+
12531255
err = bt_hci_cmd_send_sync(opcode, buf, &rsp);
12541256
if (err) {
12551257
return err;

0 commit comments

Comments
 (0)