Skip to content

Commit c0b900a

Browse files
author
Stefan Jaritz
committed
samples: bluetooth: fix advertising type for ext adv
fix: - different adv variables for normal and ext. adv Signed-off-by: Stefan Jaritz <stefan.jaritz@gmail.com>
1 parent 3d65a8e commit c0b900a

File tree

1 file changed

+13
-13
lines changed
  • samples/bluetooth/peripheral_hr/src

1 file changed

+13
-13
lines changed

samples/bluetooth/peripheral_hr/src/main.c

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,18 @@ static const struct bt_data ad[] = {
3333
static const struct bt_data sd[] = {
3434
BT_DATA(BT_DATA_NAME_COMPLETE, CONFIG_BT_DEVICE_NAME, sizeof(CONFIG_BT_DEVICE_NAME) - 1),
3535
};
36+
37+
static struct bt_le_adv_param adv_param = {
38+
.id = BT_ID_DEFAULT,
39+
.sid = 0U,
40+
.secondary_max_skip = 0U,
41+
.options = (BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CONN | BT_LE_ADV_OPT_CODED),
42+
.interval_min = BT_GAP_ADV_FAST_INT_MIN_2,
43+
.interval_max = BT_GAP_ADV_FAST_INT_MAX_2,
44+
.peer = NULL,
45+
};
46+
47+
static struct bt_le_ext_adv *adv;
3648
#endif /* !CONFIG_BT_EXT_ADV */
3749

3850
/* Use atomic variable, 2 bits for connection and disconnection state */
@@ -205,10 +217,9 @@ static int start_adv(void)
205217
printk("Advertising failed to start (err %d)\n", err);
206218
return 0;
207219
}
208-
209220
#else /* CONFIG_BT_EXT_ADV */
210221
printk("Starting Extended Advertising (connectable and non-scannable)\n");
211-
err = bt_le_ext_adv_start(ad, BT_LE_EXT_ADV_START_DEFAULT);
222+
err = bt_le_ext_adv_start(adv, BT_LE_EXT_ADV_START_DEFAULT);
212223
if (err) {
213224
printk("Failed to start extended advertising set (err %d)\n", err);
214225
return 0;
@@ -243,17 +254,6 @@ int main(void)
243254
}
244255

245256
#else /* CONFIG_BT_EXT_ADV */
246-
struct bt_le_adv_param adv_param = {
247-
.id = BT_ID_DEFAULT,
248-
.sid = 0U,
249-
.secondary_max_skip = 0U,
250-
.options = (BT_LE_ADV_OPT_EXT_ADV | BT_LE_ADV_OPT_CONN | BT_LE_ADV_OPT_CODED),
251-
.interval_min = BT_GAP_ADV_FAST_INT_MIN_2,
252-
.interval_max = BT_GAP_ADV_FAST_INT_MAX_2,
253-
.peer = NULL,
254-
};
255-
struct bt_le_ext_adv *adv;
256-
257257
printk("Creating a Coded PHY connectable non-scannable advertising set\n");
258258
err = bt_le_ext_adv_create(&adv_param, NULL, &adv);
259259
if (err) {

0 commit comments

Comments
 (0)