<?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>workload distribution between scanning and avertisment</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/102663/workload-distribution-between-scanning-and-avertisment</link><description>hello 
 I am developing an application based on nrf52832 where I &amp;quot;simultaneously&amp;quot;: 
 
 manage a fieldbus, 
 BLE advertisment to mobile 
 BLE scanning of an advertisment from a mobile to my application. 
 
 Currently both mobile and nrf52832 are implemented</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Aug 2023 09:20:13 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/102663/workload-distribution-between-scanning-and-avertisment" /><item><title>RE: workload distribution between scanning and avertisment</title><link>https://devzone.nordicsemi.com/thread/440679?ContentTypeID=1</link><pubDate>Thu, 10 Aug 2023 09:20:13 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:aee7dc01-02a3-426c-a5a5-d9e22e59cbe2</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Lorenz,&amp;nbsp;&lt;br /&gt;Sorry that I missed the part that you started 25 advertising services.&amp;nbsp;&lt;br /&gt;I think you are pushing the limit here.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you let me know the result of your test&amp;nbsp;&lt;/p&gt;
[quote user="Lorenz898989"]&lt;strong&gt;The solution that allowed me at the moment to hide the problem&amp;nbsp;is:&lt;/strong&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt; that every 100 ms I turn off the scan for 1 ms&amp;nbsp;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt; every 100ms I turn off the transmission for 1 ms &lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;(I offset the two suspensions by 50 ms)&amp;nbsp;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;(For this reason I finally relaxed the application-side parameters&amp;nbsp;)&lt;/strong&gt;&lt;/li&gt;&lt;/ol&gt;[/quote]
&lt;p&gt;Compare to when you don&amp;#39;t use this workaround ?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;It&amp;#39;s hard to explain why stopping scan and starting again would make it works better.&lt;/p&gt;
&lt;p&gt;My suggestion is to use a power profiler (Nordic PPK2) to monitor the power consumption. This way you can see when the device&amp;nbsp;does advertising and when it does scanning based on the power consumption.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please be aware that the sniffer would report all advertising packets on all channels. So you will have 3 packages for one advertising event. When on the observer on nRF52 there will be only one report for 3 packages (unless you only advertise in one channel).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In addition the architect of the sniffer where it doesn&amp;#39;t use a full-blown BLE controller make it better at scanning compare to what we have in normal application where you have multiple layers from the controller to the host to the application. The observer has to report to the application every time it receives any advertising packet. On top of that we have an OS and other tasks to handle.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: workload distribution between scanning and avertisment</title><link>https://devzone.nordicsemi.com/thread/440559?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 15:31:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4c83f402-210b-4091-8914-e82678f8e002</guid><dc:creator>Lorenz898989</dc:creator><description>&lt;p&gt;Hi&lt;/p&gt;
&lt;p&gt;the advertising hardware I am using as mobile are &lt;strong&gt;two&lt;/strong&gt; nordic nrf52832 boards.&lt;br /&gt;&lt;strong&gt;Each one&lt;/strong&gt; of the two boards &lt;strong&gt;hosts 25 separate adverising services&lt;/strong&gt;.&lt;br /&gt;In total &lt;strong&gt;I have 50&lt;/strong&gt; advertisment services.&lt;br /&gt;I am taking wireshark (nrf sniffer over nrf52840) as a reference. 2000*50 is close to 80k I would say&lt;/p&gt;
&lt;p&gt;the solution I&amp;#39;m implementing is for doing localization, like knowing what room the beacon is in, I&amp;#39;m not going to have a lot of information exchange-I just need to make sure I&amp;#39;m getting all the packets.&lt;br /&gt;That&amp;#39;s why it&amp;#39;s important for me to be sure that I receive packets from many different beacons, at the same time if I lose the scan for 10 seconds (I&amp;#39;m exaggerating) it would make localization less smooth.&lt;br /&gt;And that&amp;#39;s why I felt that I didn&amp;#39;t need either a scan or a connection.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d like to understand what you think about my approach in the previous message&amp;nbsp;&lt;/p&gt;
[quote userid="121952" url="~/f/nordic-q-a/102663/workload-distribution-between-scanning-and-avertisment/440518"]&lt;strong&gt;The solution that allowed me at the moment to hide the problem&amp;nbsp;is:&lt;/strong&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt; that every 100 ms I turn off the scan for 1 ms&amp;nbsp;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt; every 100ms I turn off the transmission for 1 ms &lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;(I offset the two suspensions by 50 ms)&amp;nbsp;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;(For this reason I finally relaxed the application-side parameters&amp;nbsp;)&lt;/strong&gt;&lt;/li&gt;&lt;/ol&gt;[/quote]
&lt;p&gt;&amp;nbsp;and/or if there is a better design pattern.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: workload distribution between scanning and avertisment</title><link>https://devzone.nordicsemi.com/thread/440548?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 14:51:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:71e01605-02ec-421f-86f3-d47b6477e089</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Cristian,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Having 80000 advertising packet per minute is a little bit unrealistic.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;How many BLE devices did you use to advertise ? Be aware that the minimum advertising interval is 20ms and there is a 10ms added random delay in between. So one advertiser can only do maximum 2000 advertising packets per minute&amp;nbsp;on average.&lt;/p&gt;
&lt;p&gt;Transmitting data via broadcasting is not very reliable, why a connection is not considered here ? You can have much more throughput with a connection.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: workload distribution between scanning and avertisment</title><link>https://devzone.nordicsemi.com/thread/440518?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 13:33:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:65c150e0-f0f0-4483-b8e9-b851e836f1ff</guid><dc:creator>Lorenz898989</dc:creator><description>&lt;p&gt;Hi Hung Bui&lt;/p&gt;
&lt;p&gt;Before contacting you I did some tests, I try to summarize them briefly:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;I tried many combinations of interval and window going down to 0x10 in each of the values you will see below (both application and mobile side)&lt;/li&gt;
&lt;li&gt;I had found an increase in the throughput by forcing interval=window, however it did not prove decisive in solving the problem (minimum value 0x15, below that I do not receive anything anymore, that is why 20 ms is my optimal setup)&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;The solution that allowed me at the moment to hide the problem&amp;nbsp;is:&lt;/strong&gt;
&lt;ol&gt;
&lt;li&gt;&lt;strong&gt; that every 100 ms I turn off the scan for 1 ms&amp;nbsp;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt; every 100ms I turn off the transmission for 1 ms &lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;(I offset the two suspensions by 50 ms)&amp;nbsp;&lt;/strong&gt;&lt;/li&gt;
&lt;li&gt;&lt;strong&gt;(For this reason I finally relaxed the application-side parameters&amp;nbsp;)&lt;/strong&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Test setup:&lt;/p&gt;
&lt;p&gt;Application running on proprietary board with nrf52832 (observer and one advertisment service). On the same board I instantiate a modbus slave, polling at 10ms and bit rate at 112500 bits/second with 100 byte reads (Polling rate does not affect, verified by switching to 1-second polling).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Mobile: I am using two nrf52dk (nrf52832) boards on which I do 25 advertisment and observer services. (I do this because I am not interested in optimizing mobile, but at the same time I want to be sure that I am receiving packets continuously and at elavated frequency.)&lt;br /&gt;This way I have 50 services broadcasting to my board.&lt;/p&gt;
&lt;p&gt;Advertisment without scanning request&lt;/p&gt;
&lt;p&gt;My goal is stability and throughout incoming BLE (before implementing step 3 on average every 60 seconds for 10 seconds I would not receive packets)&lt;br /&gt;With the sniffer I register about 80000 BLE packets per minute, on my Board about 8000 per minute with actual setup. (Added: if set on mobile 0x20 on interval and window on scan parameter i reach 14k recieved ble msg per minute)&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;My packet counter is very simple:&lt;br /&gt;as soon as I receive a packet ble I increment a counter.&lt;br /&gt;I do this increment as soon as I enter the bt_le_scan_cb_t cb observer callback set at the bt_le_scan_start level. I access the value via fieldbus&lt;/p&gt;
&lt;p&gt;Actual parameter setup&lt;/p&gt;
&lt;p&gt;on application side:&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt; &amp;nbsp;&lt;/span&gt;&lt;span&gt;BT_LE_ADV_PARAM&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;BT_LE_ADV_OPT_USE_NAME&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;0x140&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;0x190&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NULL&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp;scan_param = {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .type = &lt;/span&gt;&lt;span&gt;BT_LE_SCAN_TYPE_PASSIVE&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .options = &lt;/span&gt;&lt;span&gt;BT_LE_SCAN_OPT_FILTER_DUPLICATE&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .interval = &lt;/span&gt;&lt;span&gt;BT_GAP_SCAN_FAST_INTERVAL&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;//(0x20)&amp;nbsp;for best performace&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .window = &lt;/span&gt;&lt;span&gt;BT_GAP_SCAN_FAST_WINDOW&lt;/span&gt;&lt;span&gt;,&amp;nbsp; &amp;nbsp; &amp;nbsp; //(0x20) for best performace&lt;/span&gt;&lt;/div&gt;
&lt;div&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;on mobile side&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;BT_LE_ADV_PARAM&lt;/span&gt;&lt;span&gt;(&lt;/span&gt;&lt;span&gt;BT_LE_ADV_OPT_USE_NAME&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;0x20&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;0x20&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;/span&gt;&lt;span&gt;NULL&lt;/span&gt;&lt;span&gt;);&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt;struct&lt;/span&gt;&lt;span&gt; bt_le_scan_param scan_param = {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .type = &lt;/span&gt;&lt;span&gt;BT_LE_SCAN_TYPE_PASSIVE&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .options = &lt;/span&gt;&lt;span&gt;BT_LE_SCAN_OPT_FILTER_DUPLICATE&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .interval = &lt;/span&gt;&lt;span&gt;0x20&lt;/span&gt;&lt;span&gt;,&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; .window = &lt;/span&gt;&lt;span&gt;0x20&lt;/span&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&amp;nbsp; &amp;nbsp; };&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Thank you for the attention you are giving me.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Best r&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;Cristian&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: workload distribution between scanning and avertisment</title><link>https://devzone.nordicsemi.com/thread/440470?ContentTypeID=1</link><pubDate>Wed, 09 Aug 2023 10:59:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54b1ce55-2657-4b5a-bbb8-348e6b3bf0c7</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Lorenz,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you please provide what&amp;#39;s the scan parameters and advertising parameters you used ? We have many official examples and I am not really sure which sample you were referring to.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I would suggest to try testing again with scan window = scan interval.&amp;nbsp;&lt;br /&gt;Could you point me to the&amp;nbsp;&lt;span&gt;&amp;quot;Bluetooth: Scan &amp;amp; Advertise&amp;quot; sample ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>