<?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>Advertisement parameter max_adv_evts has no effect</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/60387/advertisement-parameter-max_adv_evts-has-no-effect</link><description>Base BLE structure ble_advertising_t contains a member structure ble_adv_mode_config_t. This structure contains two parameters that are meant to limit number of advertisements sent by the beacon : duration and max_adv_evts . Both, when set, are supposed</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 21 Apr 2020 13:20:20 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/60387/advertisement-parameter-max_adv_evts-has-no-effect" /><item><title>RE: Advertisement parameter max_adv_evts has no effect</title><link>https://devzone.nordicsemi.com/thread/245852?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2020 13:20:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:556f9544-c9e6-4797-975f-afe338bcee63</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;I see.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;As you say, it is not ideal to modify SDK modules, but it is possible. How about creating a modified ble_advertising_start function, that will be equivalent to the original, except adding that max_adv_evts()?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Why it is not properly integrated I don&amp;#39;t know. As I said, it isn&amp;#39;t much used, I believe. Remember that advertisements are not a reliable way for data transfer. You can not be sure that the receiver will pick up that exact advertisement, so changing the advertisement packet on every advertisement does not mean that this data will be received on the other side without packet loss.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertisement parameter max_adv_evts has no effect</title><link>https://devzone.nordicsemi.com/thread/245834?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2020 12:26:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8d9be7be-aefd-44ae-9079-4078f7fc50ad</guid><dc:creator>hrvoje_</dc:creator><description>&lt;p&gt;Indeed.&lt;/p&gt;
&lt;p&gt;Modifying the SDK code to use one of its documented features is not the way to go, in my opinion.&lt;/p&gt;
&lt;p&gt;Any reason why this feature is not properly integrated? I have seen Nordic staff members recommend it to users with particular use cases here on devzone.&lt;/p&gt;
&lt;p&gt;Yes, I need to send a single advertisement at a time and get informed when its sent. Therefore max_adv_evts would perfectly suit my use case.&lt;/p&gt;
&lt;p&gt;Unfortunately, timeout is not viable for me, as the only way to send a single advertisement and then timeout at the moment is to use minimal interval value of 20 together with timeout value of 40 ms (lower timeout values either result in nrf error or an advertisement is not sent at all). Wasting 20 ms is also not viable for me at this moment.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertisement parameter max_adv_evts has no effect</title><link>https://devzone.nordicsemi.com/thread/245830?ContentTypeID=1</link><pubDate>Tue, 21 Apr 2020 11:57:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e19320a6-d249-4815-b5b9-ebf97ab7c7a8</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Look in the ble_advertising start. The max_adv_evts is not fetched before&lt;/p&gt;
&lt;p&gt;ret = sd_ble_gap_adv_set_configure(&amp;amp;p_advertising-&amp;gt;adv_handle, p_advertising-&amp;gt;p_adv_data, &amp;amp;p_advertising-&amp;gt;adv_params);&lt;/p&gt;
&lt;p&gt;So you need to modify the library to use the max_adv_evts if you need to use it.&lt;/p&gt;
&lt;p&gt;Is there a particular reason for why you need to use this? I believe it is not much used. Is it possible to use the timeout instead, so that you don&amp;#39;t need to modify the ble_advertising.c file?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertisement parameter max_adv_evts has no effect</title><link>https://devzone.nordicsemi.com/thread/245646?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2020 18:27:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f44fe9ce-2f00-479f-a1f9-447444261de5</guid><dc:creator>hrvoje_</dc:creator><description>&lt;p&gt;Hi Edvin, thank you for your answer!&lt;/p&gt;
&lt;p&gt;I can indeed verify that your suggestion works.&lt;/p&gt;
&lt;p&gt;I have previously tried to add the line&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;em&gt;p_advertising-&amp;gt;adv_params.max_adv_evts = 1;&lt;/em&gt;&lt;/p&gt;
&lt;div&gt;inside &lt;strong&gt;ble_advertising_init()&lt;/strong&gt;, where the other adv_params are set, just before&lt;br /&gt;&lt;em&gt;&lt;br /&gt;ret = sd_ble_gap_adv_set_configure(&amp;amp;p_advertising-&amp;gt;adv_handle, NULL, &amp;amp;p_advertising-&amp;gt;adv_params);&lt;br /&gt;&lt;br /&gt;&lt;/em&gt;
&lt;div&gt;&lt;span&gt;is called, but to no avail. Any idea why this does not work? Shouldn&amp;#39;t the &lt;strong&gt;max_adv_evts&lt;/strong&gt; parameter then be set inside sd configuration and not get erased by that memset just like &lt;strong&gt;duration&lt;/strong&gt;, &lt;strong&gt;interval&lt;/strong&gt; and the rest of adv_params ?&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Advertisement parameter max_adv_evts has no effect</title><link>https://devzone.nordicsemi.com/thread/245599?ContentTypeID=1</link><pubDate>Mon, 20 Apr 2020 14:23:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f12338dd-c7c7-4383-8eac-97035a895821</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I have not confirmed this with the freertos version, but I tested with the non-freertos version, and I suspect you may be seeing the same thing.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Where do you set the max_adv_evts parameter? I suspect it is before you call&amp;nbsp;&lt;/p&gt;
&lt;p&gt;ble_advertising_start(&amp;amp;m_advertising, BLE_ADV_MODE_FAST);&lt;/p&gt;
&lt;p&gt;Is that correct?&lt;/p&gt;
&lt;p&gt;The reason I ask is that inside ble_advertising start(), the line:&lt;/p&gt;
&lt;p&gt;memset(&amp;amp;p_advertising-&amp;gt;adv_params, 0, sizeof(p_advertising-&amp;gt;adv_params));&lt;/p&gt;
&lt;p&gt;is called. So anything you have stored in adv_params will be erased, and set according to the parameters that you used in advertising_init(). I can&amp;#39;t see that max_adv_evts is included in advertising_init(), so I assume this is what you are seeing.&lt;/p&gt;
&lt;p&gt;If you try to add the line:&lt;/p&gt;
&lt;p&gt;p_advertising-&amp;gt;adv_params.max_adv_evts = 5;&lt;/p&gt;
&lt;p&gt;before the line:&lt;/p&gt;
&lt;p&gt;switch (p_advertising-&amp;gt;adv_mode_current)&lt;/p&gt;
&lt;p&gt;in ble_advertising_start(), you should see that it times out after 5 advertisements. At least it did in my case.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>