<?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>Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/93771/dynamically-updating-advertising-service-data-not-working</link><description>Hello, 
 
 In my advertising_init function, I have added service data. This works and can be seen when I use nRF Connect app on my phone. 
 I&amp;#39;ve read and used the post below to update manufacturing data dynamically, which works. 
 
 
 However, when using</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 07 Dec 2023 20:36:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/93771/dynamically-updating-advertising-service-data-not-working" /><item><title>RE: Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/thread/459435?ContentTypeID=1</link><pubDate>Thu, 07 Dec 2023 20:36:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2e2cadfe-449c-4528-88c6-609993175bb6</guid><dc:creator>arshi</dc:creator><description>&lt;p&gt;Hello, could you please share the code of how you updated the service data. Thanks in advance!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/thread/396180?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2022 11:15:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d2629ee6-4f7d-45f8-a6ac-570c5f46e586</guid><dc:creator>jerome.sc</dc:creator><description>&lt;p&gt;Ok, this makes sense.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/thread/396137?ContentTypeID=1</link><pubDate>Thu, 17 Nov 2022 08:54:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:95c5b420-7dd3-46e7-92c6-3e00194cc81a</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;No, you do not need to update the configuration struct. (In that case, you pass the same old for reference, which is different than passing a new&amp;nbsp;instance of advertising data).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/thread/395853?ContentTypeID=1</link><pubDate>Tue, 15 Nov 2022 16:18:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8719c91e-9996-4eed-8bdc-c8b6e51c3139</guid><dc:creator>jerome.sc</dc:creator><description>&lt;p&gt;Ok, I&amp;#39;ve fixed it so it updates the service data.&lt;/p&gt;
&lt;p&gt;Would I still need to add the following lines when I am updating the service data?&lt;/p&gt;
&lt;p&gt;init.config.ble_adv_fast_enabled = true;&lt;br /&gt;init.config.ble_adv_fast_interval = APP_ADV_INTERVAL;&lt;br /&gt;init.config.ble_adv_fast_timeout = APP_ADV_DURATION;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/thread/395845?ContentTypeID=1</link><pubDate>Tue, 15 Nov 2022 15:53:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b58e3480-30df-4911-abc2-c832cb942b6c</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;These screenshots looks as expected, given the code. When you update the advertising data, you need to provide everything. Here you start off with an advertising packet that holds different types of information (configured in your&amp;nbsp;advertising_init()), but when you&amp;nbsp;update it you make an advertising packet that includes almost nothing. If you want it to contain the name, UUIDs, etc, that it originally did, you need to continue to include that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/thread/395723?ContentTypeID=1</link><pubDate>Tue, 15 Nov 2022 09:21:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:147d96a5-912d-4493-a73e-9fadc12da620</guid><dc:creator>jerome.sc</dc:creator><description>&lt;p&gt;The ble_advertising_init function works with adding service data as shown in the screenshot, from the device called CL.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot_5F00_20221115_2D00_094951_5F00_nRF-Connect.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;It&amp;#39;s pretty much as soon as this function is called the device stops advertising.&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void adv_data_update(void)
{
  ret_code_t err_code;
  ble_advdata_service_data_t    new_serv_data;

  new_advdata.p_service_data_array = &amp;amp;new_serv_data;

  NRF_LOG_INFO(&amp;quot;Updating advertising data!&amp;quot;);

  uint8_t data[1]                            = {0x11};
  new_serv_data.data.p_data                  = data;
  new_serv_data.data.size                    = sizeof(data);  

  err_code = ble_advertising_advdata_update(&amp;amp;m_advertising, &amp;amp;new_advdata, NULL);
  APP_ERROR_CHECK(err_code);

  NRF_LOG_INFO(&amp;quot;Updated advertising data!&amp;quot;);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;From the debug window, it shows the function is being executed, and both the NRF_LOG_INFO get executed.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1668504120779v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I also noticed that after I try to update the service data, on the nRF connect app the device seems to still be found and shows a minimal amount of information. Even the name of the device has been set the N/A.&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/Screenshot_5F00_20221115_2D00_093700_5F00_nRF-Connectt.jpg" /&gt;&lt;/p&gt;
&lt;p&gt;I attached the&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_template_5F00_nrf52840.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_template_5F00_nrf52840.zip&lt;/a&gt;&amp;nbsp;project file I was working on, although it&amp;#39;s pretty much the template project using an nRF52840.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/thread/395687?ContentTypeID=1</link><pubDate>Tue, 15 Nov 2022 07:43:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:30bfa674-a916-42a9-8d8d-4aa97b80e333</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Most SDK examples has logging enabled by default. The definitions you listed here should be good assuming you have them in sdk_config.h. Assuming your code enables logging (just refer to any BLE example in the SDK), you should see RTT logs with this configuration in either Segger Embedded Studio&amp;nbsp;directly if using that, or&amp;nbsp;with Segger RTT Viewer. You do not need to use logging though, you can also build with DEBUG as you write, and inspect the error handler from a debugger.&lt;/p&gt;
&lt;p&gt;Note that the point about logging was assuming that a APP_ERROR_CHECK hit a non-zero&amp;nbsp;return value, as that is typically what has happened when people see things stop working. If advertising stops without you having explicitly stopped it or it timed out, then an error occurred, and in most cases it will have been caught by an APP_ERROR_CHECK() if you are using that as the example code (and you always should, as you want to catch any errors that happen, both while debugging and in the field). Therefor, this is normally the first step when trying to figure out what has happened and why.&lt;/p&gt;
&lt;p&gt;If you have problems with that, you can also use other methods to track execution and find where things went wrong. Then inspect return values. As you write that this problem happened when you try to update advertising data, the first thing I would suspect was that there was a problem with the parameters to the call to&amp;nbsp;ble_advertising_init(), and that returned an error code. Is that it?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/thread/395365?ContentTypeID=1</link><pubDate>Fri, 11 Nov 2022 15:06:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d5dbb1f-a334-419c-8bf7-bc856d7f3787</guid><dc:creator>jerome.sc</dc:creator><description>&lt;p&gt;How do you enable logging? I added these settings in my app_config file, which I used for checking ram/flash size. I have also added DEBUG to the preprocessor definitions.&lt;/p&gt;
&lt;p&gt;#define NRF_LOG_BACKEND_RTT_ENABLED 1&lt;br /&gt;#define NRF_LOG_BACKEND_UART_ENABLED 0&lt;br /&gt;#define NRF_LOG_ENABLED 1&lt;br /&gt;#define NRF_LOG_DEFERRED 1&lt;br /&gt;#define NRF_LOG_DEFAULT_LEVEL 4&lt;br /&gt;#define NRF_SDH_BLE_LOG_ENABLED 1&lt;br /&gt;#define NRF_SDH_BLE_LOG_LEVEL 4&lt;br /&gt;#define NRF_SDH_LOG_ENABLED 1&lt;br /&gt;#define NRF_SDH_LOG_LEVEL 4&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;When checking in debug mode nothing shows in the output window. If I read and print the err_code using the line below, it reads zero.&lt;/p&gt;
&lt;p&gt;&amp;nbsp; NRF_LOG_INFO(&amp;quot;Error: %d&amp;quot;, err_code);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Dynamically updating advertising service data not working</title><link>https://devzone.nordicsemi.com/thread/395323?ContentTypeID=1</link><pubDate>Fri, 11 Nov 2022 12:54:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cdf1e8fa-c0ef-497c-b01c-777e3d0baf2e</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;As you see that advertising stops, that probably means that something went wrong. Most likely, an APP_ERROR_CHECK detected a error return code. So the firsts thing to do is to enable logging or inspect the error handler to find out which APP_ERROR_CHECK that was. Then you will know which function call returned which error code, and that is a good starting point for debugging.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>