<?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>How to synchronize application with radio notifications?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/67775/how-to-synchronize-application-with-radio-notifications</link><description>Hello, 
 I&amp;#39;m using nRF52840 devboards and am running the NUS-examples on two devboards (peripheral and central) with SoftDevice S140 (SDK 17.0.2). 
 I want to synchronize my application code (sending on the peripheral side) with the radio to enhance data</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 03 Nov 2020 08:48:51 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/67775/how-to-synchronize-application-with-radio-notifications" /><item><title>RE: How to synchronize application with radio notifications?</title><link>https://devzone.nordicsemi.com/thread/278205?ContentTypeID=1</link><pubDate>Tue, 03 Nov 2020 08:48:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0c9c7407-fa58-40b1-b348-4ab4901092a5</guid><dc:creator>Edvin</dc:creator><description>[quote user="Dominik Weber"]Does the&amp;nbsp;NRF_ERROR_RESOURCES error mean that there is currently no connection event ongoing?[/quote]
&lt;p&gt;&amp;nbsp;No. The NRF_ERROR_RESOURCES means that your softdevice queue is full, and you have to wait for at least one of the packets to be successfully transmitted and Aacked before you can queue another packet. This will not happen until the next connection event (800µs after the radio notification.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Maximizing the throughput is a quite common question here on DevZone. Try to search on it. If you look at the softdevice specification: &lt;a href="https://infocenter.nordicsemi.com/topic/sds_s140/SDS/s1xx/ble_data_throughput/ble_data_throughput.html"&gt;Bluetooth Low Energy Throughput&lt;/a&gt;, you can see that the maximum possible theoretical throughput is ~1.3Mbps, using the parameters that you are using. The throughput can be increased a little bit by increasing the connection interval, but it is also more sensitive to packet loss.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In order to increase the throughput you need to enable Data Length Extention, and make sure that your softdevice queue is full at all times (or at least when the connection event occurs). The softdevice queue is full when ble_nus_data_send() returns NRF_ERROR_RESOURCES. NB: The last packet, that returned NRF_ERROR_RESOURCES was&amp;nbsp;&lt;strong&gt;not&lt;/strong&gt; queued.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;The ble_app_uart + ble_app_uart_c example pair is throughput optimized, I think. I you send dummy data (all zero&amp;#39;s) from your main-loop while it returns NRF_SUCCESS, and just count the length of the packets received by the central, you can use a timer to calculate the throughput. NB: Don&amp;#39;t print the data on UART. That is slow, and your application will not be able to handle the incoming data correctly.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;BR,&lt;/p&gt;
&lt;p&gt;Edvin&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to synchronize application with radio notifications?</title><link>https://devzone.nordicsemi.com/thread/278131?ContentTypeID=1</link><pubDate>Mon, 02 Nov 2020 15:15:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c6943b7-3a67-4cd3-b99e-5281ee750f6b</guid><dc:creator>Dominik Weber</dc:creator><description>&lt;p&gt;Thanks Edvin,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The idea is that the radio notification indicates that a connection event will occur soon (800&amp;micro;s before the event), so that the application can send all its queued data (since the last connection event) to the ble stack for sending.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The task is waiting (pending, but without CPU interaction) in line 5 for the task notification which is given by the radio notification ISR. So this means that the task will be woken when there will be a connection event (the data is queued by another task).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I will check what&amp;nbsp;&lt;span&gt;ble_nus_data_send() usually returns.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Does the&amp;nbsp;NRF_ERROR_RESOURCES error mean that there is currently no connection event ongoing?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In general:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;What I wan&amp;#39;t to achieve is a maximum throughput with BLE (I&amp;#39;m already on 2Mbit PHY) and I don&amp;#39;t really know how to achieve this. I thought that synchronizing the application with the radio like this is the way to go.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you have any other tips to achieve high throughput? I studied the maximum throughput example and have adjusted most of the suggested parameters (DLE, CI = 50ms, 2MbitPHY, MTU=247).&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to synchronize application with radio notifications?</title><link>https://devzone.nordicsemi.com/thread/277828?ContentTypeID=1</link><pubDate>Fri, 30 Oct 2020 13:50:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3e8f893a-f242-49d0-9276-fc69c416463b</guid><dc:creator>Edvin</dc:creator><description>&lt;p&gt;Hello,&lt;/p&gt;
&lt;p&gt;I don&amp;#39;t quite understand your setup. What role does the radio notification have?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;From where is the&amp;nbsp;vbleCommunicationTask() triggered? (it may be that you said it, but my FreeRTOS knowledge is not the best).&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Why do you need to synchronize the queuing of data to 800µs before the connection event? And what do you see from the throughput? What does&amp;nbsp;ble_nus_data_send() usually return? Do you see that it sometimes returns more NRF_ERROR_RESOURCES? Or how does it behave when the throughput is inconsistent?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>