<?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>Set UUID in Advertising Data in Peripheral LBS</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/86913/set-uuid-in-advertising-data-in-peripheral-lbs</link><description>Hi, 
 
 
 Using the Peripheral LBS sample, is there a way to add advertising data to use both the UUID and name? 
 I assume this is to be configured in the bt_data ad declaration and is depended on what _type and expected variables under BT_DATA function</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 13 Apr 2022 23:01:44 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/86913/set-uuid-in-advertising-data-in-peripheral-lbs" /><item><title>RE: Set UUID in Advertising Data in Peripheral LBS</title><link>https://devzone.nordicsemi.com/thread/363256?ContentTypeID=1</link><pubDate>Wed, 13 Apr 2022 23:01:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0fb8530e-d1b0-4ff2-b95c-8a033b4d07c5</guid><dc:creator>TysonYee</dc:creator><description>&lt;p&gt;Hi Kazi,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Thank you for the response, simply changing the BT_DATA function calls between the advertising packet and scan response&amp;nbsp;was the solution.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Tyson&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Set UUID in Advertising Data in Peripheral LBS</title><link>https://devzone.nordicsemi.com/thread/363217?ContentTypeID=1</link><pubDate>Wed, 13 Apr 2022 14:07:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:962a2e8e-fd5b-4264-961d-e6ac5ba34125</guid><dc:creator>Kazi Afroza Sultana</dc:creator><description>&lt;p&gt;Hello Tyson,&lt;/p&gt;
&lt;p&gt;I think it is possible to set UIID and device name of the service as advertising data.&amp;nbsp; We have an introductory tutorial for Bluetooth Low Energy you can look at&amp;nbsp;&lt;a href="https://github.com/edvinand/custom_ncs_ble_service_sample"&gt;GitHub - edvinand/custom_ncs_ble_service_sample&lt;/a&gt;.&amp;nbsp; It shows how to add the device name and the UUID of the service in advertising data-&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;For example&lt;/strong&gt; in the below code snippet, it shows the device name that is set in the config file, how it is applied in advertising packet inside&amp;nbsp;&lt;span&gt;ad[] and&amp;nbsp; inside scan response packet sd[]&lt;/span&gt;&amp;nbsp;, how randomly generated UUID is added. So when we want to advertise both of these , we can start advertising from bluetooth_init()&lt;span&gt;&amp;nbsp;after the bt_init_ok semaphore has been taken.&lt;/span&gt;&lt;/p&gt;
&lt;pre&gt;#&lt;span&gt;define&lt;/span&gt; &lt;span&gt;DEVICE_NAME&lt;/span&gt; CONFIG_BT_DEVICE_NAME
#&lt;span&gt;define&lt;/span&gt; &lt;span&gt;DEVICE_NAME_LEN&lt;/span&gt; (&lt;span&gt;sizeof&lt;/span&gt;(DEVICE_NAME)-&lt;span&gt;1&lt;/span&gt;)


&lt;span&gt;static&lt;/span&gt; &lt;span&gt;const&lt;/span&gt; &lt;span&gt;struct&lt;/span&gt; bt_data ad[] = {
    &lt;span&gt;BT_DATA_BYTES&lt;/span&gt;(BT_DATA_FLAGS, (BT_LE_AD_GENERAL | BT_LE_AD_NO_BREDR)),
    &lt;span&gt;BT_DATA&lt;/span&gt;(BT_DATA_NAME_COMPLETE, DEVICE_NAME, DEVICE_NAME_LEN)
};

&lt;span&gt;static&lt;/span&gt; &lt;span&gt;const&lt;/span&gt; &lt;span&gt;struct&lt;/span&gt; bt_data sd[] = {
    &lt;span&gt;BT_DATA_BYTES&lt;/span&gt;(BT_DATA_UUID128_ALL, BT_UUID_REMOTE_SERV_VAL),
};&lt;/pre&gt;
&lt;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;int bluetooth_init(struct bt_conn_cb *bt_cb, struct bt_remote_service_cb *remote_cb)
{
int err;
LOG_INF(&amp;quot;Initializing Bluetooth&amp;quot;);

if (bt_cb == NULL || remote_cb == NULL) {
return NRFX_ERROR_NULL;
}
bt_conn_cb_register(bt_cb);
remote_service_callbacks.notif_changed = remote_cb-&amp;gt;notif_changed;
remote_service_callbacks.data_received = remote_cb-&amp;gt;data_received;

err = bt_enable(bt_ready);
if (err) {
LOG_ERR(&amp;quot;bt_enable returned %d&amp;quot;, err);
return err;
}

k_sem_take(&amp;amp;bt_init_ok, K_FOREVER);

err = bt_le_adv_start(BT_LE_ADV_CONN, ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
if (err){
LOG_ERR(&amp;quot;couldn&amp;#39;t start advertising (err = %d&amp;quot;, err);
return err;
}

return err;
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;You can look at this tutorial and try to implement similar way in your project. Let us know the outcome.&lt;/p&gt;
&lt;p&gt;Thanks.&lt;/p&gt;
&lt;p&gt;Best Regards,&lt;/p&gt;
&lt;p&gt;Kazi Afroza Sultana&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>