<?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>Updating scan response packet whilst advertising</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/92994/updating-scan-response-packet-whilst-advertising</link><description>In my application, I&amp;#39;m using the Scan Response Packet to transmit some device related information, rather than requiring Clients to connect to get this. I&amp;#39;m using NCS v2.0.0 and testing on an nRF52-DK. 
 I&amp;#39;m using the following to store the scan response</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 22 Oct 2022 02:11:59 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/92994/updating-scan-response-packet-whilst-advertising" /><item><title>RE: Updating scan response packet whilst advertising</title><link>https://devzone.nordicsemi.com/thread/391971?ContentTypeID=1</link><pubDate>Sat, 22 Oct 2022 02:11:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60bb6b5b-9a47-446e-ae15-90c859102f65</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Hieu,&lt;/p&gt;
&lt;p&gt;Just stumbled across&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/14071/check-if-currently-advertising"&gt;this link on DevZone&lt;/a&gt;.&amp;nbsp; I know its a few years old, and probably refers to the older soft devices which I&amp;#39;m not using, but it is basically saying you need to keep track of whether your device is advertising or connected yourself.&amp;nbsp; I had been doing this, but also had a DISCONNECTED state that I set my flag to when it disconnected.&amp;nbsp; Seems that the peripheral will automatically return to advertising once its disconnected, and so I now set my flag to ADVERTISING in my .disconnected call back.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve come from an Infineon/Cypress background, and they have a bunch of API&amp;#39;s you can call to get the current state of the stack, and I just assumed it was something pretty standard.&lt;/p&gt;
&lt;p&gt;Anyway, I&amp;#39;ll keep this in mind and just use my own flags to keep track of what&amp;#39;s going on with my BLE stack&lt;/p&gt;
&lt;p&gt;Cheers,&lt;/p&gt;
&lt;p&gt;Mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating scan response packet whilst advertising</title><link>https://devzone.nordicsemi.com/thread/391931?ContentTypeID=1</link><pubDate>Fri, 21 Oct 2022 14:18:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec19b08f-9d04-4c56-9f56-dfc084a92b28</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Mike,&lt;/p&gt;
&lt;p&gt;Glad to know you got it worked out.&lt;/p&gt;
&lt;p&gt;Unfortunately, I also don&amp;#39;t think there is any API to help you directly get the advertising status.&lt;/p&gt;
&lt;p&gt;However, I found that if you use Advertisement Set, you can setup some helpful callback while calling&amp;nbsp;&lt;a href="https://developer.nordicsemi.com/nRF_Connect_SDK/doc/latest/zephyr/connectivity/bluetooth/api/gap.html#c.bt_le_ext_adv_create"&gt;bt_le_ext_adv_create()&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;If you feel like you have a strong use case, I think you can open a &lt;a href="https://github.com/zephyrproject-rtos/zephyr/blob/main/.github/ISSUE_TEMPLATE/feature_request.md"&gt;feature request&lt;/a&gt; in the Zephyr project. If you do, please share it with the community by&amp;nbsp;giving the link here.&lt;/p&gt;
&lt;p&gt;Hope that helps.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating scan response packet whilst advertising</title><link>https://devzone.nordicsemi.com/thread/391759?ContentTypeID=1</link><pubDate>Thu, 20 Oct 2022 22:43:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b812edb9-1360-45c7-ab9a-5e4301662198</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;Hi Hieu,&lt;/p&gt;
&lt;p&gt;Got it sorted.&amp;nbsp; Had nothing to do with how I had set everything up, but was in fact related to an if() statement I had my&amp;nbsp;bt_le_adv_update_data(ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd)); call inside.&amp;nbsp; Basically, the if() statement wasn&amp;#39;t ever becoming true, so I wasn&amp;#39;t ever sending out the updated scan response data.&amp;nbsp; Should have checked my code better!&lt;/p&gt;
&lt;p&gt;A quick related question - the if() statement was basically checking to see if I had disconnected and was advertising again, as I update some of the info that I send out on the scan response packet via a BLE connection to a client.&amp;nbsp; So, before I attempt to update the scan response packet I was doing a check to ensure I was back advertising.&lt;/p&gt;
&lt;p&gt;I do this with a bool that I set to&amp;nbsp;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;bt_status&lt;/span&gt;&lt;span&gt; = &lt;/span&gt;&lt;span&gt;BLE_ADVERTISING&lt;/span&gt;&lt;span&gt;;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;within my .disconnected call back.&amp;nbsp; But that basically assumes that if I&amp;#39;m disconnected, I&amp;#39;m advertising, as I don&amp;#39;t actually know of any way of checking the current BLE status.&amp;nbsp; It could, for example, have stopped completely.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Do you know if there are any API&amp;#39;s that will return the current BLE status?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Cheers,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Mike&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating scan response packet whilst advertising</title><link>https://devzone.nordicsemi.com/thread/391519?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 17:26:35 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c9be482-0084-4257-a7b1-de097ae520c5</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Mike Austin,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I notice that the data field of your Scan Response BT_DATA macro&amp;nbsp;is NULL, however that is where you supply data to the API. That is most likely the problem. I am not sure how you update the Scan Response data like&amp;nbsp;with that setup though?&lt;/p&gt;
&lt;p&gt;On my end, I set up as followed and just calling bt_le_adv_update_data() worked. As I started with a non-connectable base, I test without the&amp;nbsp;BT_LE_ADV_OPT_CONNECTABLE flag. I don&amp;#39;t think it changes anything though.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;static uint8_t mfg_data[BT_GAP_ADV_MAX_ADV_DATA_LEN-2] = { 0xff, 0xff, 0x00 };

static const struct bt_data sd[] = {
	BT_DATA(BT_DATA_MANUFACTURER_DATA, mfg_data, BT_GAP_ADV_MAX_ADV_DATA_LEN-2),
};

...

	while(1) {
		k_sleep(K_MSEC(1000));

		mfg_data[2]++;
		printk(&amp;quot;mfg_data = {%02x, %02x, %02x}\n&amp;quot;, mfg_data[0], mfg_data[1], mfg_data[2]);

		err = bt_le_adv_update_data(ad, ARRAY_SIZE(ad), sd, ARRAY_SIZE(sd));
		printk(&amp;quot;bt_le_adv_update_data %d\n\n&amp;quot;, err); 
		if (err) return;
	}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Could you please try it and let me know if it works?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Updating scan response packet whilst advertising</title><link>https://devzone.nordicsemi.com/thread/391307?ContentTypeID=1</link><pubDate>Wed, 19 Oct 2022 00:55:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30edc82d-c9fe-4d79-a34a-1dffd4035822</guid><dc:creator>Mike Austin (LPI)</dc:creator><description>&lt;p&gt;A bit of info I should have included:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define BT_LE_ADV_CONN_LSR_AD BT_LE_ADV_PARAM(BT_LE_ADV_OPT_CONNECTABLE |\
												BT_LE_ADV_OPT_USE_NAME |\
												BT_LE_ADV_OPT_FORCE_NAME_IN_AD,\
												BT_GAP_ADV_FAST_INT_MIN_2, \
												BT_GAP_ADV_FAST_INT_MAX_2, NULL)&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>