From 8f7df0b49f81e330a59094c0c0412c0b698b68bf Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Th=C3=A9o=20Battrel?= Date: Wed, 24 Apr 2024 06:57:55 +0200 Subject: [PATCH] Bluetooth: Samples: Dev name in AD instead of SD MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit With the deprecation of `BT_LE_ADV_OPT_USE_NAME` and `BT_LE_ADV_OPT_FORCE_NAME_IN_AD` samples were updated to not use the macro adding the device name in the advertising/scan response data anymore. Instead the name was explicitly added to the scan response data in `periodic_adv` sample. But because it was using an extended advertiser and was already adding data in the AD, the name should have been put in the advertising data and not the scan response data. Update the sample to add the device name in the advertising data. Signed-off-by: Théo Battrel --- samples/bluetooth/periodic_adv/src/main.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/samples/bluetooth/periodic_adv/src/main.c b/samples/bluetooth/periodic_adv/src/main.c index 6abee0c0812..9b584966ce7 100644 --- a/samples/bluetooth/periodic_adv/src/main.c +++ b/samples/bluetooth/periodic_adv/src/main.c @@ -8,11 +8,11 @@ static uint8_t mfg_data[] = { 0xff, 0xff, 0x00 }; -static const struct bt_data ad[] = { +static const struct bt_data per_adv_ad[] = { BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, 3), }; -static const struct bt_data sd[] = { +static const struct bt_data ad[] = { BT_DATA(BT_DATA_NAME_COMPLETE, CONFIG_BT_DEVICE_NAME, sizeof(CONFIG_BT_DEVICE_NAME) - 1), }; @@ -38,7 +38,7 @@ int main(void) } /* Set advertising data to have complete local name set */ - err = bt_le_ext_adv_set_data(adv, NULL, 0, sd, ARRAY_SIZE(sd)); + err = bt_le_ext_adv_set_data(adv, ad, ARRAY_SIZE(ad), NULL, 0); if (err) { printk("Failed to set advertising data (err %d)\n", err); return 0; @@ -75,7 +75,7 @@ int main(void) mfg_data[2]++; printk("Set Periodic Advertising Data..."); - err = bt_le_per_adv_set_data(adv, ad, ARRAY_SIZE(ad)); + err = bt_le_per_adv_set_data(adv, per_adv_ad, ARRAY_SIZE(per_adv_ad)); if (err) { printk("Failed (err %d)\n", err); return 0;