|
13 | 13 | #include <zephyr/bluetooth/bluetooth.h> |
14 | 14 | #include <zephyr/bluetooth/hci.h> |
15 | 15 | #include <zephyr/bluetooth/mesh.h> |
| 16 | +#if defined(CONFIG_BT_LL_SOFTDEVICE) |
| 17 | +#include <sdc_hci_vs.h> |
| 18 | +#endif |
16 | 19 |
|
17 | 20 | #include "common/bt_str.h" |
18 | 21 |
|
@@ -134,6 +137,28 @@ static inline struct bt_mesh_ext_adv *gatt_adv_get(void) |
134 | 137 | #endif /* CONFIG_BT_MESH_ADV_EXT_GATT_SEPARATE */ |
135 | 138 | } |
136 | 139 |
|
| 140 | +static int set_adv_randomness(uint8_t handle, int rand_us) |
| 141 | +{ |
| 142 | +#if defined(CONFIG_BT_LL_SOFTDEVICE) |
| 143 | + struct net_buf *buf; |
| 144 | + sdc_hci_cmd_vs_set_adv_randomness_t *cmd_params; |
| 145 | + |
| 146 | + buf = bt_hci_cmd_create(SDC_HCI_OPCODE_CMD_VS_SET_ADV_RANDOMNESS, sizeof(*cmd_params)); |
| 147 | + if (!buf) { |
| 148 | + LOG_ERR("Could not allocate command buffer"); |
| 149 | + return -ENOMEM; |
| 150 | + } |
| 151 | + |
| 152 | + cmd_params = net_buf_add(buf, sizeof(*cmd_params)); |
| 153 | + cmd_params->adv_handle = handle; |
| 154 | + cmd_params->rand_us = rand_us; |
| 155 | + |
| 156 | + return bt_hci_cmd_send_sync(SDC_HCI_OPCODE_CMD_VS_SET_ADV_RANDOMNESS, buf, NULL); |
| 157 | +#else |
| 158 | + return 0; |
| 159 | +#endif /* defined(CONFIG_BT_LL_SOFTDEVICE) */ |
| 160 | +} |
| 161 | + |
137 | 162 | static int adv_start(struct bt_mesh_ext_adv *adv, |
138 | 163 | const struct bt_le_adv_param *param, |
139 | 164 | struct bt_le_ext_adv_start_param *start, |
@@ -456,6 +481,13 @@ int bt_mesh_adv_enable(void) |
456 | 481 | if (err) { |
457 | 482 | return err; |
458 | 483 | } |
| 484 | + |
| 485 | + if (IS_ENABLED(CONFIG_BT_LL_SOFTDEVICE) && adv->tag & BT_MESH_FRIEND_ADV) { |
| 486 | + err = set_adv_randomness(adv->instance->handle, 0); |
| 487 | + if (err) { |
| 488 | + LOG_ERR("Failed to set zero randomness: %d", err); |
| 489 | + } |
| 490 | + } |
459 | 491 | } |
460 | 492 |
|
461 | 493 | return 0; |
|
0 commit comments