<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://devzone.nordicsemi.com/cfs-file/__key/system/syndication/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:atom="http://www.w3.org/2005/Atom"><channel><title>I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid</link><description>Hello. It is developed using nrf52832 (S132 v7.0.1, SDK v17.0.0) as a peripheral device. 
 I want to conditionally switch the advertised UUID to another UUID. There is &amp;quot;sd_ble_uuid_vs_add&amp;quot; as an API to set the advertisement UUID, but I don&amp;#39;t know how</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 21 Feb 2022 08:47:00 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid" /><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/354055?ContentTypeID=1</link><pubDate>Mon, 21 Feb 2022 08:47:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd78d3b2-f58d-436d-a43b-7ef29eaf4a79</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="sdi_kei"]I referred to this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/19861/how-to-set-service-uuid-for-central-and-peripheral"&gt;ticket&lt;/a&gt; for the setting method.&lt;br /&gt;Since &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN + 1&amp;quot; is set for the second advertisement, I interpreted it as being used in a staggered manner.[/quote]
&lt;p&gt;Aha, I see - thank you for clarifying.&lt;/p&gt;
[quote user="sdi_kei"]It was said that the whitelist could not be set, so as you told me, I took the method of stopping it, resetting it, and then starting advertising.[/quote]
&lt;p&gt;Alright, great - I am glad to hear that this is working as intended now!&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/354014?ContentTypeID=1</link><pubDate>Mon, 21 Feb 2022 00:22:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4a5a3bde-731c-41f2-839b-4e5ddbd01198</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/353857#353857"]How did you find these offsets?[/quote]
&lt;p&gt;I referred to this &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/19861/how-to-set-service-uuid-for-central-and-peripheral"&gt;ticket&lt;/a&gt; for the setting method.&lt;br /&gt;Since &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN + 1&amp;quot; is set for the second advertisement, I interpreted it as being used in a staggered manner.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/353857#353857"]&lt;em&gt;ble_adv_whitelist_enabled&amp;nbsp;&lt;/em&gt;and then restart without whitelist or temporarily disable whitelist if needed.[/quote]
&lt;p&gt;It was said that the whitelist could not be set, so as you told me, I took the method of stopping it, resetting it, and then starting advertising.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/353857?ContentTypeID=1</link><pubDate>Fri, 18 Feb 2022 13:09:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6d9483bd-a529-4115-8143-3d49cebad481</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="sdi_kei"]I&amp;#39;m using sd_ble_uuid_vs_add to add a UUID to the SoftDevice table.&lt;br /&gt;However, there is other data in the SoftDevice table, so if you do not specify the added number correctly, you will refer to other data.&lt;br /&gt;The definition indicating the number is &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN&amp;quot;.&lt;br /&gt;In my case, it was off by 18, so I was able to correctly set the UUID of the SoftDevice table in the advertisement payload by doing &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN + 18&amp;quot;.[/quote]
&lt;p&gt;Hm.. I am not entirely sure that I follow.. How did you find these offsets?&lt;br /&gt;The UUID type field is indeed the index relative to BLE_UUID_TYPE_VENDOR_BEGIN like described in&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.3.0/group___b_l_e___c_o_m_m_o_n___f_u_n_c_t_i_o_n_s.html#ga265b4251110a15120d0aa97e5152163b"&gt;the sd_ble_uuid_vs_add API Reference documentation&lt;/a&gt;, and it will depend on how many UUID&amp;#39;s and other information you have populated the SoftDevice table with already.&lt;/p&gt;
[quote user="sdi_kei"]Thank you. Before adding the UUID, I would like to use it to remove the previously added UUID.[/quote]
&lt;p&gt;Great! This should keep your memory from overflowing.&lt;/p&gt;
[quote user="sdi_kei"]You can&amp;#39;t enable or disable the whitelist at the same time.&lt;br /&gt;It is possible to disable it with &amp;quot;ble_advertising_restart_without_whitelist&amp;quot;, but is there an API to enable it?[/quote]
&lt;p&gt;No, you can not advertise both with and without whitelist - this would effectively mean without whitelist.&lt;br /&gt;It is also correct that there is no specific function to enable whitelist, instead you can enable whitelist in the advertising configuration &lt;em&gt;p_advertising-&amp;gt;adv_modes_config.ble_adv_whitelist_enabled&amp;nbsp;&lt;/em&gt;and then restart without whitelist or temporarily disable whitelist if needed.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/353256?ContentTypeID=1</link><pubDate>Wed, 16 Feb 2022 08:07:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ca2e30d-26a0-4607-bd09-3a89f330c231</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/353119#353119"]I am not exactly sure about what you mean when you say this, since which UUID is advertised is independent of the SoftDevice table - it only depends on which UUID&amp;#39;s you populate the advertising packet with. Perhaps I am misunderstanding you here?[/quote]
&lt;p&gt;Here it means setting the UUID from the SoftDevice table in the advertisement payload.&lt;/p&gt;
&lt;p&gt;I&amp;#39;m using sd_ble_uuid_vs_add to add a UUID to the SoftDevice table.&lt;br /&gt;However, there is other data in the SoftDevice table, so if you do not specify the added number correctly, you will refer to other data.&lt;br /&gt;The definition indicating the number is &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN&amp;quot;.&lt;br /&gt;In my case, it was off by 18, so I was able to correctly set the UUID of the SoftDevice table in the advertisement payload by doing &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN + 18&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/353119#353119"]Yes, adding more and more UUID&amp;#39;s to the SoftDevice table will eat up the memory over time - you can use the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___c_o_m_m_o_n___f_u_n_c_t_i_o_n_s.html#gaf9814a42465b2d51fba4aae3a05bdb95"&gt;sd_ble_vs_remove&lt;/a&gt;&amp;nbsp;function to free this memory as according to the function API.[/quote]
&lt;p&gt;Thank you. Before adding the UUID, I would like to use it to remove the previously added UUID.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/353119#353119"]&lt;span&gt;In general, the&amp;nbsp;&lt;/span&gt;ble_advertising_advdata_update function does only update advertising data payload - not the configuration - so if you need to make changes to the advertising configuration you will instead need to stop the advertising, reconfigure, and then restart the advertising.[/quote]
&lt;p&gt;You can&amp;#39;t enable or disable the whitelist at the same time.&lt;br /&gt;It is possible to disable it with &amp;quot;ble_advertising_restart_without_whitelist&amp;quot;, but is there an API to enable it?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/353119?ContentTypeID=1</link><pubDate>Tue, 15 Feb 2022 13:59:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9a94b015-8d84-4a45-a7e1-cd2428c46f0a</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user="sdi_kei"]The reason why it was advertised with another UUID was that it was out of the SoftDevice table by that amount because the service and characteristic were set. The problem was solved by adding the number of deviations to &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN&amp;quot;.[/quote]
&lt;p&gt;I am not exactly sure about what you mean when you say this, since which UUID is advertised is independent of the SoftDevice table - it only depends on which UUID&amp;#39;s you populate the advertising packet with. Perhaps I am misunderstanding you here?&lt;/p&gt;
[quote user="sdi_kei"]Since sd_ble_uuid_vs_add is performed every time advertising_update is called, the number to be added to &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN&amp;quot; will change. Also, I think that sd_ble_uuid_vs_add will put pressure on the memory space every time. Is there a way to prevent pressure?[/quote]
&lt;p&gt;Yes, adding more and more UUID&amp;#39;s to the SoftDevice table will eat up the memory over time - you can use the &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.2.0/group___b_l_e___c_o_m_m_o_n___f_u_n_c_t_i_o_n_s.html#gaf9814a42465b2d51fba4aae3a05bdb95"&gt;sd_ble_vs_remove&lt;/a&gt;&amp;nbsp;function to free this memory as according to the function API.&lt;/p&gt;
[quote user="sdi_kei"]Also, &amp;quot;ble_adv_whitelist_enabled&amp;quot; is set to true in m_adv_init, but I want to be able to select whether to use whitelist or not every time I call advertising_update. Is there a way to choose?[/quote]
&lt;p&gt;&lt;span&gt;You may use the&amp;nbsp;ble_advertising_restart_without_whitelist function to restart the current advertising mode without whitelist enabled.&lt;br /&gt;In general, the&amp;nbsp;&lt;/span&gt;ble_advertising_advdata_update function does only update advertising data payload - not the configuration - so if you need to make changes to the advertising configuration you will instead need to stop the advertising, reconfigure, and then restart the advertising.&lt;span&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
[quote user="sdi_kei"]I thought about &amp;quot;ble_advertising_restart_without_whitelist&amp;quot; to temporarily disable it, but how long will this temporary period last? Can it be used for selection?[/quote]
&lt;p&gt;The&amp;nbsp;ble_advertising_restart_without_whitelist function will restart the current advertising mode without whitelist, so it will have the same duration / timeout as the advertising mode you are in when this function is called.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Karl&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/353045?ContentTypeID=1</link><pubDate>Tue, 15 Feb 2022 10:05:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ea8a0e7-4e75-49d1-8013-8179cbca4486</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/351775#351775"]Please see &lt;a href="https://github.com/NordicPlayground/nRF52-Bluetooth-Course"&gt;this BLE Course github repository for a detailed explanation of how to create and add a custom service&lt;/a&gt; to the SoftDevice.[/quote]
&lt;p&gt;Using this link as a reference, I was able to create the following code that dynamically changes the UUID.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define BLE_BASE_UUID        {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15}
#define BLE_ADV_UUID         0xFFFF
#define COMPANY_IDENTIFIER   0xFFFF                                /**&amp;lt; Company identifier for Nordic Semiconductor ASA as per www.bluetooth.org. */
#define BLE_UUID_TYPE_ALPHA  BLE_UUID_TYPE_VENDOR_BEGIN + 18
#define BLE_UUID_TYPE_BETA   BLE_UUID_TYPE_VENDOR_BEGIN + 19


BLE_ADVERTISING_DEF(m_advertising);

// Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.
static ble_uuid_t m_adv_uuids[2];

static uint8_t ble_update_cnt = 0x00;

// Advertising data structure. This structure contains all options and data needed for encoding and setting the advertising data.
static ble_advdata_t m_adv_data = 
{
    .flags                   = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE,
    .p_tx_power_level        = NULL;
    .uuids_complete.uuid_cnt = NULL,
    .uuids_complete.p_uuids  = NULL,
    .p_manuf_specific_data   = NULL;
};

// Options for the different advertisement modes.
static ble_adv_modes_config_t m_adv_init = 
{
    .ble_adv_whitelist_enabled      = true,
    .ble_adv_on_disconnect_disabled = true,
    .ble_adv_fast_enabled           = true,
    .ble_adv_fast_interval          = APP_ADV_INTERVAL,
    .ble_adv_fast_timeout           = APP_ADV_DURATION,
};

// Initialize the advertisement.
static void advertising_init(void)
{
    ret_code_t               err_code;
    ble_uuid_t               ble_uuid;
    ble_uuid128_t            base_uuid = {BLE_BASE_UUID};
    ble_advertising_init_t   adv_init;
    ble_advdata_manuf_data_t manuf_data;
    
    int8_t tx_power_level;

    memset(&amp;amp;adv_init, 0, sizeof(adv_init));
    memset(&amp;amp;manuf_data, 0, sizeof(manuf_data));

    // UUID Setting.
    m_adv_uuids[0].uuid = BLE_ADV_UUID;
    m_adv_uuids[0].type = BLE_UUID_TYPE_ALPHA;

    m_adv_data.uuids_complete.uuid_cnt = 0x01;
    m_adv_data.uuids_complete.p_uuids  = &amp;amp;m_adv_uuids[0];

    err_code = sd_ble_uuid_vs_add(&amp;amp;base_uuid, &amp;amp;ble_uuid.type);
    APP_ERROR_CHECK(err_code);

    // Tx Power setting.
    tx_power_level = 4;
    m_adv_data.p_tx_power_level = &amp;amp;tx_power_level;

    // Manufacturer Specific Data Setting.
    manuf_data.company_identifier    = COMPANY_IDENTIFIER;
    manuf_data.data.size             = NULL;
    manuf_data.data.p_data           = NULL;
    m_adv_data.p_manuf_specific_data = &amp;amp;manuf_data;

    adv_init.advdata     = m_adv_data;
    adv_init.config      = m_adv_init;
    adv_init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&amp;amp;m_advertising, &amp;amp;adv_init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&amp;amp;m_advertising, APP_BLE_CONN_CFG_TAG);

    return;
}

// Updating advertising data.
static void advertising_update(void)
{
    ret_code_t               err_code;
    ble_advdata_t            adv_data;
    ble_uuid_t               ble_uuid;
    ble_uuid128_t            base_uuid;
    ble_advdata_manuf_data_t manuf_data;
    uint8_t                  ble_adv_uuid_update[] = {0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x2A, 0x2B, 0x2C, 0x2D};

    memset(&amp;amp;adv_data, 0, sizeof(adv_data));

    // UUID Setting.
    if (ble_update_cnt &amp;lt;= 0x0A) {
        ble_update_cnt+;
    } else {
        ble_update_cnt = 0x00;
    }
    ble_adv_uuid_update[0] = ble_update_cnt;

    memcpy(base_uuid.uuid128, ble_adv_uuid_update, sizeof(ble_adv_uuid_update));
    m_adv_uuids[1].uuid = BLE_ADV_UUID;
    m_adv_uuids[1].type = BLE_UUID_TYPE_BETA;

    adv_data.uuids_complete.uuid_cnt = 0x01;
    adv_data.uuids_complete.p_uuids  = &amp;amp;m_adv_uuids[1];

    err_code = sd_ble_uuid_vs_add(&amp;amp;base_uuid, &amp;amp;ble_uuid.type);

    // Flags Setting.
    adv_data.flags = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE;

    // Tx power Setting.
    adv_data.p_tx_power_level = NULL;

    // Manufacturer Specific Data Setting.
    manuf_data.company_identifier    = COMPANY_IDENTIFIER;
    manuf_data.data.size             = NULL;
    manuf_data.data.p_data           = NULL;
    adv_data.p_manuf_specific_data = &amp;amp;manuf_data;

    err_code = ble_advertising_advdata_update(&amp;amp;m_advertising, &amp;amp;adv_data, NULL);
    APP_ERROR_CHECK(err_code);

    return;
}&lt;/pre&gt;&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/351775#351775"]Please provide examples of the code you run when this happens, what the output of this code is, and how it diverges from what you would have expected the code to do.[/quote]
&lt;p&gt;The reason why it was advertised with another UUID was that it was out of the SoftDevice table by that amount because the service and characteristic were set. The problem was solved by adding the number of deviations to &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN&amp;quot;.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;However, a question arose here.&lt;br /&gt;Since sd_ble_uuid_vs_add is performed every time advertising_update is called, the number to be added to &amp;quot;BLE_UUID_TYPE_VENDOR_BEGIN&amp;quot; will change. Also, I think that sd_ble_uuid_vs_add will put pressure on the memory space every time. Is there a way to prevent pressure?&lt;/p&gt;
&lt;p&gt;Also, &amp;quot;ble_adv_whitelist_enabled&amp;quot; is set to true in m_adv_init, but I want to be able to select whether to use whitelist or not every time I call advertising_update. Is there a way to choose?&lt;br /&gt;I thought about &amp;quot;ble_advertising_restart_without_whitelist&amp;quot; to temporarily disable it, but how long will this temporary period last? Can it be used for selection?&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/351775?ContentTypeID=1</link><pubDate>Tue, 08 Feb 2022 12:00:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6011b8b7-8e05-456c-9f40-c076b1e225dd</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello again,&lt;/p&gt;
[quote user="sdi_kei"]I don&amp;#39;t understand what is shown in the uart example of the ble app, so please tell me what it is.[/quote]
&lt;p&gt;What is it that you would like me to elaborate or explain? Apologies, but I do not think I am understanding you correctly here.&lt;/p&gt;
[quote user="sdi_kei"]I have interpreted the 128-bit base UUID in my own way, but is it correct?[/quote]
&lt;p&gt;You may generate your own base UUID for custom services, yes.&lt;br /&gt;Please see &lt;a href="https://github.com/NordicPlayground/nRF52-Bluetooth-Course"&gt;this BLE Course github repository for a detailed explanation of how to create and add a custom service&lt;/a&gt; to the SoftDevice.&lt;/p&gt;
[quote user="sdi_kei"]I&amp;#39;m checking how to update the dynamic advertisement data and creating a process, but if I dynamically set m_adv_uuids to uuids_complete.p_uuids, it will be advertised with a different base UUID.[/quote]
&lt;p&gt;Please provide examples of the code you run when this happens, what the output of this code is, and how it diverges from what you would have expected the code to do.&lt;br /&gt;Please also note that the UUID&amp;nbsp;might be given in Big-Endian, while we use small-endian in our SDK. This means that the byte-ordering of the UUID should be put in reverse, to conform to the SDK standard.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/351672?ContentTypeID=1</link><pubDate>Tue, 08 Feb 2022 06:51:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5c22c03c-950f-45c3-98db-6e98d95f3a59</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/351308#351308"]Could you elaborate what you mean when you say that you would like to &amp;#39;set it&amp;#39;?[/quote]
&lt;p&gt;I don&amp;#39;t understand what is shown in the uart example of the ble app, so please tell me what it is.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Use sd_ble_uuid_vs_add to add a 128bit base UUID to your soft device. This base UUID is linked by setting BLE_UUID_TYPE_VENDOR_BEGIN in m_adv_uuids. The base UUID is used by setting this m_adv_uuids to uuids_complete.p_uuids.&lt;/p&gt;
&lt;p&gt;I have interpreted the 128-bit base UUID in my own way, but is it correct?&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/351308#351308"]The example is a SES project, however you could still see how the dynamic advertising data update is done by looking at the main.c file in the project.[/quote]
&lt;p&gt;I&amp;#39;m checking how to update the dynamic advertisement data and creating a process, but if I dynamically set m_adv_uuids to uuids_complete.p_uuids, it will be advertised with a different base UUID.&lt;br /&gt;I don&amp;#39;t know why something like that happens.&lt;br /&gt;Please let me know if you know.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/351308?ContentTypeID=1</link><pubDate>Fri, 04 Feb 2022 11:49:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b7f94a1-6a9e-4c0c-b72b-9604b320ed5e</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="sdi_kei"]The explanation was insufficient. I&amp;#39;m sorry.[/quote]
&lt;p&gt;No need to apologize, I am just trying to understand your issue better so that I may provide you better help resolving it.&lt;/p&gt;
[quote user="sdi_kei"]I only know how to set a 128bit UUID is sd_ble_uuid_vs_add. I checked the SDK&amp;#39;s advertising_init, but I couldn&amp;#39;t figure out how to set the 128bit UUID. I would like to know how to set it.[/quote]
&lt;p&gt;The sd_ble_uuid_vs_add is the function for adding the UUID as a base UUID in the SoftDevice. However, this does not have anything to do with the advertising directly.&lt;br /&gt;Adding datafields to the advertising data payload is not the same as adding UUIDs the SoftDevice table.&lt;br /&gt;Could you elaborate what you mean when you say that you would like to &amp;#39;set it&amp;#39;?&lt;br /&gt;If you mean that you would like to add the UUID to your advertising data payload, then you should do it as demonstrated in the ble app uart example.&lt;/p&gt;
[quote user="sdi_kei"]It is ble_app_update_advertising_data.zip, but when I tried to start it with IAR Embedded Workbench, &amp;quot;Could not open the project&amp;quot; was displayed and I could not confirm the operation.[/quote]
&lt;p&gt;Oh, I was not aware that you were using IAR.&lt;br /&gt;The example is a SES project, however you could still see how the dynamic advertising data update is done by looking at the main.c file in the project.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/351302?ContentTypeID=1</link><pubDate>Fri, 04 Feb 2022 11:36:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:967b6172-da82-496d-b96f-f433b7ab9b1e</guid><dc:creator>sdi_kei</dc:creator><description>[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/351265#351265"]I am not sure what you are asking me about here[/quote]
&lt;p&gt;The explanation was insufficient. I&amp;#39;m sorry.&lt;br /&gt;I only know how to set a 128bit UUID is sd_ble_uuid_vs_add. I checked the SDK&amp;#39;s advertising_init, but I couldn&amp;#39;t figure out how to set the 128bit UUID. I would like to know how to set it.&lt;/p&gt;
[quote userid="87869" url="~/f/nordic-q-a/84398/i-want-to-conditionally-switch-the-advertised-uuid-to-another-uuid/351265#351265"]At the very end of the blogpost there is also a minimal example that shows how you could perform dynamic updates of the advertising payload.[/quote]
&lt;p&gt;It is ble_app_update_advertising_data.zip, but when I tried to start it with IAR Embedded Workbench, &amp;quot;Could not open the project&amp;quot; was displayed and I could not confirm the operation.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/351265?ContentTypeID=1</link><pubDate>Fri, 04 Feb 2022 10:00:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6fd0db1e-1e20-4736-a477-66551a8b5ca5</guid><dc:creator>Karl Ylvisaker</dc:creator><description>[quote user="sdi_kei"]I checked advertising_init in the SDK&amp;#39;s BLE peripheral example, but how do I set the 128-bit base UUID?[/quote]
&lt;p&gt;I am not sure what you are asking me about here - would you like the advertising payload to contain the custom UUID?&lt;br /&gt;If so, you may do so as demonstrated in the BLE app uart example - which is close to what you are doing currently.&lt;/p&gt;
[quote user="sdi_kei"]However, I will consider it again with reference to the blog you taught me.[/quote]
&lt;p&gt;Great, I am happy to hear that you found the blogpost useful! :)&lt;br /&gt;At the very end of the blogpost there is also a minimal example that shows how you could perform dynamic updates of the advertising payload.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/351251?ContentTypeID=1</link><pubDate>Fri, 04 Feb 2022 09:18:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a4bf1b46-d38f-4a91-9061-5cfe1e504c5e</guid><dc:creator>sdi_kei</dc:creator><description>&lt;p&gt;Hello.&lt;/p&gt;
&lt;p&gt;I misunderstood that if I did sd_ble_uuid_vs_add at the very beginning, it would set the advertised UUID. I have listed the current advertising_init code.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define BLE_BASE_UUID  {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x10, 0x11, 0x12, 0x13, 0x14, 0x15}
#define BLE_ADV_UUID   0xFFFF
BLE_ADVERTISING_DEF(m_advertising);

// Bluetooth Low Energy UUID type, encapsulates both 16-bit and 128-bit UUIDs.
static ble_uuid_t m_adv_uuids[] = 
{
    {BLE_ADV_UUID, BLE_UUID_TYPE_VENDOR_BEGIN},
};

// Advertising data structure. This structure contains all options and data needed for encoding and setting the advertising data.
static ble_advdata_t m_adv_data = 
{
    .flags                        = BLE_GAP_ADV_FLAGS_LE_ONLY_GENERAL_DISC_MODE,
    .uuids_complete.uuid_cnt      = sizeof(m_adv_uuids) / sizeof(m_adv_uuids[0]),
    .uuids_complete.p_uuids       = m_adv_uuids,
};

// Options for the different advertisement modes.
static ble_adv_modes_config_t m_adv_init = 
{
    .ble_adv_whitelist_enabled      = true,
    .ble_adv_on_disconnect_disabled = true,
    .ble_adv_fast_enabled           = true,
    .ble_adv_fast_interval          = APP_ADV_INTERVAL,
    .ble_adv_fast_timeout           = APP_ADV_DURATION,
};

// Function for the GAP initialization.
static void gap_params_init(void)
{
    ret_code_t    err_code;
    ble_uuid_t    uuid_type;
    ble_uuid128_t base_uuid = {BLE_BASE_UUID};

    err_code = sd_ble_uuid_vs_add(&amp;amp;base_uuid, uuid_type);
    APP_ERROR_CHECK(err_code);

    return;
}

// Initialize the advertisement.
static void advertising_init(void)
{
    ret_code_t err_code;
    ble_advertising_init_t adv_init;

    memset(&amp;amp;adv_init, 0, sizeof(adv_init));

    adv_init.advdata     = m_adv_data;
    adv_init.config      = m_adv_init;
    adv_init.evt_handler = on_adv_evt;

    err_code = ble_advertising_init(&amp;amp;m_advertising, &amp;amp;adv_init);
    APP_ERROR_CHECK(err_code);

    ble_advertising_conn_cfg_tag_set(&amp;amp;m_advertising, APP_BLE_CONN_CFG_TAG);

    return;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;I checked advertising_init in the SDK&amp;#39;s BLE peripheral example, but how do I set the 128-bit base UUID?&lt;/p&gt;
&lt;p&gt;I stopped considering the method of dynamically changing the advertisement payload because the advertisement packet switching was not successful before. However, I will consider it again with reference to the blog you taught me.&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: I want to conditionally switch the advertised UUID to another UUID.</title><link>https://devzone.nordicsemi.com/thread/351233?ContentTypeID=1</link><pubDate>Fri, 04 Feb 2022 07:42:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:64cc9b1d-0fee-4aba-b8f3-012f962106e3</guid><dc:creator>Karl Ylvisaker</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
[quote user=""]I want to conditionally switch the advertised UUID to another UUID.&lt;br /&gt;There is &amp;quot;sd_ble_uuid_vs_add&amp;quot; as an API to set the advertisement UUID[/quote]
&lt;p&gt;The contents of the advertising payload and the added vendor specific UUID are independent of each other. The &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v7.3.0/group___b_l_e___c_o_m_m_o_n___f_u_n_c_t_i_o_n_s.html#ga265b4251110a15120d0aa97e5152163b"&gt;sd_ble_uuid_vs_add&lt;/a&gt; function adds the vendor specific UUID to the SoftDevice table - it does not populate the advertising payload.&lt;br /&gt;The advertising payload will have to be populated separately, where you can add which ever valid data field to the payload as you would like. You could see this done in the&amp;nbsp;&lt;em&gt;advertising_init&amp;nbsp;&lt;/em&gt;function of the BLE peripheral examples in the SDK.&lt;br /&gt;If you are using the BLE advertising library you could also &lt;a href="https://devzone.nordicsemi.com/guides/short-range-guides/b/bluetooth-low-energy/posts/how-to-update-advertising-data-dynamically-using-ble-advertising-library"&gt;take a look at this blogpost&lt;/a&gt;&amp;nbsp;to see how you may dynamically update your advertising payload, along with an example of this.&lt;br /&gt;&lt;br /&gt;Best regards,&lt;br /&gt;Karl&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>