<?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>DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/71712/dle-goes-to-27-when-using-phy_2m</link><description>Hello, We&amp;#39;re trying to optimize the data transfer rate from our nRF52832 based peripheral device to the mobile phone. Tested with two different BLE &amp;gt;= 5 Android phones we encountered a weird behavior and would like to get your help to resolve it. Our</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 23 Mar 2021 11:10:07 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/71712/dle-goes-to-27-when-using-phy_2m" /><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/301394?ContentTypeID=1</link><pubDate>Tue, 23 Mar 2021 11:10:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:66507748-aaf0-45e2-b170-97c4ea1d9cde</guid><dc:creator>plippo</dc:creator><description>[quote userid="2121" url="~/f/nordic-q-a/71712/dle-goes-to-27-when-using-phy_2m/301277#301277"]The size of the TX buffer of the softdevice is automatically determined by the configuration of &lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH&amp;nbsp; and the supported PHYs.&amp;nbsp;&lt;/span&gt;[/quote]
&lt;p&gt;Yes, I saw that in the documentation but in practise I&amp;#39;ve never gotten more than 4 packets (of DLE=165) before getting NRF_ERROR_RESOURCES no matter how much I give SD memory or attribute space.&lt;/p&gt;
[quote userid="2121" url="~/f/nordic-q-a/71712/dle-goes-to-27-when-using-phy_2m/301277#301277"]Note that the&amp;nbsp;HVN_TX_COMPLETE only comes after the connection event is finished. So you may have to think about queueing the packet even before the event.&amp;nbsp;[/quote]
&lt;p&gt;How is this compatible with the sample code you sent? In that code the new packet is sent in the HVN_TX_COMPLETE -handler so by definition it would not make it to the same connection event.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/301277?ContentTypeID=1</link><pubDate>Mon, 22 Mar 2021 16:43:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:376729c9-de5f-4b18-86f5-e7d013eba7d5</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Petri,&amp;nbsp;&lt;br /&gt;The size of the TX buffer of the softdevice is automatically determined by the configuration of &lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH&amp;nbsp; and the supported PHYs.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;In theory the softdevice is capable of transmitting&amp;nbsp;data in the full event length configured. I would strongly suggest to try to test with the throughput example we have in the SDK where we can achieve 1.3Mbps with 2Mbps PHY.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Note that it&amp;#39;s not always correct that the smaller the interval the higher the throughput you will have. For larger packet size there will be a sweet spot that you can fit the most of the packets inside the connection event without any &amp;quot;idle&amp;quot; period.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I&amp;#39;m not very certain about this &amp;quot;the SD has already &amp;quot;gotten tired of waiting&amp;quot; . As far as know, the softdevice is capable of refilling the buffer on the go when it&amp;#39;s transmitting its buffer. So if there is available buffer it will accept the queue.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;Note that the&amp;nbsp;HVN_TX_COMPLETE only comes after the connection event is finished. So you may have to think about queueing the packet even before the event.&amp;nbsp;&lt;br /&gt;But it&amp;#39;s still strange to me that the buffer is not big enough to cover the transmitting of the whole registered event length. There could be a chance that it&amp;#39;s only calculated for 1Mbps PHY not 2Mbps PHY. And that&amp;#39;s why you would need to refill the buffer even before the&amp;nbsp;HVN_TX_COMPLETE&amp;nbsp;event.&amp;nbsp;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/300966?ContentTypeID=1</link><pubDate>Fri, 19 Mar 2021 14:02:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:17e6f897-20e3-44ae-8b3f-8111978df0b2</guid><dc:creator>plippo</dc:creator><description>&lt;p&gt;Finally got forward with this. Looks like the issue is related to FreeRTOS thread timings in relation to SD event handling. I&amp;#39;ve simplified our protocol code as much as possible and took into use semaphore protected sending (producer-consumer pattern) with event handler triggered resend (a bit like in your sample code). This refactoring resulted a worsening of transfer speed from 50kB/s to 10kB/s.&lt;/p&gt;
&lt;p&gt;As far as I understand the situation is as follows:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Data is sent from datasource to the&amp;nbsp;protocol handler for sending over BLE notification&lt;/li&gt;
&lt;li&gt;The protocol code pushes the notification to the SD (sd_ble_gatts_hvx). The SD receives max 4 updates until it responds with NRF_ERROR_RESOURCES. Setting semaphore count to 4 protects from this happening so the sender just waits until the event comes.&lt;/li&gt;
&lt;li&gt;SD sends BLE events (&lt;span&gt;BLE_GATTS_EVT_HVN_TX_COMPLETE)&amp;nbsp;&lt;/span&gt;via IRQ which triggers calls to nrf_sdh_evts_poll in a high priority event thread.&lt;/li&gt;
&lt;li&gt;Event handler releases the semaphore allowing next &lt;span&gt;notification&amp;nbsp;&lt;/span&gt;to be pushed to SD.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;When the PHY_2M is in use the transmission of the 4 packets of&amp;nbsp; up-to 165 B takes about 3.0-4.2 ms depending on the size of the packets. By the time the &lt;span&gt;HVN_TX_COMPLETE-&lt;/span&gt;event is handled and semaphore is triggered and the sending thread awoken to push the update into SD, the SD has already &amp;quot;gotten tired of waiting&amp;quot;. SD then decides that there is no more data to send until next interval which results anything from 3-7&amp;nbsp;packets sent&amp;nbsp;per interval. During the waiting the sending thread of course fills the buffer in SD so that when the new interval starts, there is again 4 ready to send.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;When PHY_1M is used the 4 packet memory lasts for 5-6 ms which gives the rest of the system enough time to handle sending the new data to SD resulting more packets per interval.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;I tried to add more memory to the softdevice (linker RAM start address) as well as larger ATTR_TABLE in sdk_config.h, but neither changed the situation. No matter what I did the SD only accepts 4 notifications. &lt;strong&gt;Is there a way to increase the buffer on the SD?&lt;br /&gt;&lt;br /&gt;&lt;/strong&gt;I also tried to call &amp;quot;&lt;span&gt;nrf_sdh_evts_poll&amp;quot; directly in the IRQ handler, but that didn&amp;#39;t work with FreeRTOS threads for some reason (got stuck. maybe thats why your nrf_sdh_freertos.c also uses the event thread).&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;Now that I know what causes the slowdown I can try to design the&amp;nbsp;protocol code to respond as fast as possible, but I&amp;#39;m not too optimistic...&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/298096?ContentTypeID=1</link><pubDate>Fri, 05 Mar 2021 13:21:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c7822f10-62c9-4ebb-ab39-46e6737e98e1</guid><dc:creator>plippo</dc:creator><description>&lt;p&gt;I did some timing printouts in the event handling and the delay from IRQ to event handling was just a couple of ms, so nothing is hanging there.&lt;br /&gt;&lt;br /&gt;I tried with 100ms connection interval and the amount per event seems to vary from 3 packets to 8 (2.5ms - 7ms, most packets were big, couple of small ones in the middle) which is the same as with interval 45 ms.&lt;br /&gt;&lt;br /&gt;Next I set the conn interval to 7,5 (like your sample, negotiations resulted 11ms) and the situation was identical. 3-8 packets per interval but total speed was of course much faster since transmission continued much sooner (about 50% time spent waiting for next interval).&lt;br /&gt;&lt;br /&gt;I&amp;#39;ll continue studying this next week but it&amp;#39;s really weird that PHY1M doesn&amp;#39;t cause this issue...&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/298001?ContentTypeID=1</link><pubDate>Fri, 05 Mar 2021 10:19:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b17fc67-9c38-409e-b005-04c2b4814636</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Petri,&amp;nbsp;&lt;br /&gt;We would need to have a look at your code to see how you&amp;nbsp;call&amp;nbsp;&lt;span&gt;nrf_sdh_evts_poll(). At which priority level do you have your sending thread running ?&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;From what I know of, if you don&amp;#39;t pull the event out from the stack event buffer, it will start NACKing the packets from the central. I suspect that there could be some share buffer here and when you don&amp;#39;t pull the event out of the buffer, you have less buffer for the notification.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;I would suggest to test on how many notification packets you can queue until you receive&amp;nbsp;&lt;span&gt;NRF_ERROR_RESOURCES in your case (you can use a long connection interval like 1s to make it easier to test). And compare that to what you have in my example.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;You can also think of implementing the same way of calling&amp;nbsp;&lt;span&gt;nrf_sdh_evts_poll() in my example and see if it has any effect on the throughput.&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/297983?ContentTypeID=1</link><pubDate>Fri, 05 Mar 2021 09:06:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:20ccd7d5-aaf3-4d85-ac9a-708cd02ea6bc</guid><dc:creator>plippo</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;I finally found the DK in our office and managed to run some tests. I did three runs with the following settings:&lt;br /&gt;&lt;br /&gt;1. Your sample unmodified (I did have to give Softdevice 256 bytes more RAM)&lt;br /&gt;2. sample with conn_interval min &amp;amp; max set to 45ms (to match what our settings default to when connecting to Android)&lt;br /&gt;3. Conn interval of 45ms and DLE set to match ours (165)&lt;br /&gt;&lt;br /&gt;In all cases the transfer speed was high and the packets are transferred over most of the connection interval.&lt;br /&gt;&lt;br /&gt;I&amp;#39;m really running out of ideas on what could cause our weird behavior. Also a curious detail: in the 165 DLE test the DLE&amp;nbsp;gets set to 165 / 165 on 3rd try or something. (initially 165 / 27 since phone wants 251 / 27).&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/UART_5F00_Test_5F00_45ms.btt"&gt;devzone.nordicsemi.com/.../UART_5F00_Test_5F00_45ms.btt&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/UART_5F00_Test_5F00_45ms_5F00_DLE165.btt"&gt;devzone.nordicsemi.com/.../UART_5F00_Test_5F00_45ms_5F00_DLE165.btt&lt;/a&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/UART_5F00_Test_5F00_orig.btt"&gt;devzone.nordicsemi.com/.../UART_5F00_Test_5F00_orig.btt&lt;/a&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;strong&gt;EDIT&lt;/strong&gt;: An idea occurred to me. I&amp;#39;m using a separate thread for handling SD events which calls nrf_sdh_evts_poll()&amp;nbsp; in a loop when triggered in SD_EVT_IRQHandler. The event thread has the same priority as my sending thread, but it should get time to run during the sleep of the send thread. Assuming the event thread is not being run properly, is it possible that the softdevice stops sending data if the events are not delivered?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/295886?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 15:32:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:034b1dd0-2725-4cdd-8cb7-47b52cb3cae1</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Petri,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you try to reproduce the issue on a simple application so that we can have a test here ?&amp;nbsp;&lt;br /&gt;I also attached here a small example that you can test. It&amp;#39;s a modified version of ble_app_uart that send 100kB of data (500 packets of 200bytes each). At 7.5ms I can see the throughput of around 100kB/s when the phone is close.&amp;nbsp;&lt;br /&gt;You can test by connect using the nRFToolbox app =&amp;gt;Uart Profile to connect, and then click button 0 on the nRF52DK. Or you can use NRF Connect, and enable CCCD before testing.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The fundamental difference I can observe here is that the MD bit at the end of the connection event is set on the last packet from the slave, meaning the slave can send more data but the central didn&amp;#39;t want to receive more.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When in your case the slave didn&amp;#39;t want to send more data. The example is from SDK v17.0.2 and for nRF52832 DK. Please use RTT logging when testing.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_uart-_2D00_-Througput.zip"&gt;devzone.nordicsemi.com/.../ble_5F00_app_5F00_uart-_2D00_-Througput.zip&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;img src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/pastedimage1614094346473v1.png" alt=" " /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/295818?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 12:31:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1372fad4-8e44-4947-a3be-6d0f71932071</guid><dc:creator>plippo</dc:creator><description>&lt;p&gt;This loo&lt;em&gt;p&lt;/em&gt; resides in a &amp;quot;dlServiceSend&amp;quot; function which is part of our communication stack. There is a thread outside that calls that code in a loop until there is no more data&amp;nbsp;to send. So the next call comes in as soon as the while loop (and the function) is exited. &lt;br /&gt;&lt;br /&gt;In my debug printouts it is clearly visible that the waiting happens in the while loop above until the connection interval is over (usually around 35 ms). So in short there is data waiting to be sent which causes it to wait in that while loop because&amp;nbsp;sd_ble_gatts_hvx returns&amp;nbsp;NRF_ERROR_RESOURCES.&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/295798?ContentTypeID=1</link><pubDate>Tue, 23 Feb 2021 10:48:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ad1993f2-f1de-4503-913e-f21540810513</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Petri,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In your code:&lt;br /&gt;&lt;pre class="ui-code" data-mode="text"&gt;while (true)
{
    error = sd_ble_gatts_hvx(m_conn_handle, &amp;amp;hvx_params);
    if (error != NRF_ERROR_RESOURCES) break;
    threadSleepMs(1);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;What happens when sd_ble_gatts_hvx returns NRF_SUCCESS&amp;nbsp; ? From what I can see it will just break out of the while loop.&amp;nbsp;&lt;br /&gt;How do you queue the next packets when the first one is successfully queued ?&amp;nbsp;&lt;br /&gt;Please try to test with just queueing more data right away when the previous packet is successfully queued.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/295557?ContentTypeID=1</link><pubDate>Mon, 22 Feb 2021 12:16:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1bf4ca7a-ae62-4af1-95bd-cc4b3ead6c15</guid><dc:creator>plippo</dc:creator><description>&lt;p&gt;Hello,&lt;br /&gt;&lt;br /&gt;Got back to office and did the following test runs (Ellisys files as attachment). Short result: No changes in behaviour from previous tests.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;- 1M1M (request 1M on rx &amp;amp; tx) =&amp;gt; &lt;strong&gt;fast&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;- 2M2M (&lt;span&gt;request 2M on rx &amp;amp; tx) =&amp;gt; &lt;strong&gt;slow&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;- 2MxM (request 2M on tx, 1M or 2M on rx) =&amp;gt; &lt;strong&gt;slow&lt;/strong&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;- RetAutoOnReq: Don&amp;#39;t ask for PHY, just if requested set rx &amp;amp; tx to&amp;nbsp;&lt;/span&gt;BLE_GAP_PHY_AUTO (phone chooses 1M) =&amp;gt; &lt;strong&gt;fast&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;- 2M2M_EL400 (request&amp;nbsp;2M on rx &amp;amp; tx, set&amp;nbsp;NRF_SDH_BLE_GAP_EVENT_LENGTH to 400) =&amp;gt; &lt;strong&gt;slow&lt;/strong&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/PHY2MTests.zip"&gt;devzone.nordicsemi.com/.../PHY2MTests.zip&lt;/a&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/295389?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 15:18:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3d3c68e4-ae8f-4f81-9181-bf6791f85cce</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Petri,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please send the 1Mbps trace.&lt;/p&gt;
&lt;p&gt;Could you try increasing the&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH&amp;nbsp; ?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;If you test the throughput example in the NRF5 SDK you can find that at 2M PHY the throughput can be achieved is around 1.4Mbps.&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/295317?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 12:01:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3c722bc2-1a56-4288-af6d-17932b72931c</guid><dc:creator>plippo</dc:creator><description>&lt;p&gt;My code reads next piece of data to send as soon as previous has been queued. The sending code calls in the loop with max 1ms delay until the packet goes thru (which trigger yet another send):&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span&gt; /&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;/ Try to send until there is buffers available (with wait, so we don&amp;#39;t consume CPU)&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; while (true)&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; {&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; error = sd_ble_gatts_hvx(m_conn_handle, &amp;amp;hvx_params);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; if (error != NRF_ERROR_RESOURCES) break;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&amp;nbsp; &amp;nbsp; threadSleepMs(1);&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt; }&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;/div&gt;
&lt;p&gt;The debug logging over the while look indicates that the code handles about 7-8 sends on first try and then waits for 30-40 ms until it succeeds.&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Event length should be ok (and indeed it works with PHY_1M):&lt;/p&gt;
&lt;div&gt;
&lt;div&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;#define NRF_SDH_BLE_GAP_EVENT_LENGTH 36&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: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/295293?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 10:37:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:27d4feff-96ec-4f3f-8c4e-ff49b64d5264</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Petri,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Could you also send the 1M sniffer for comparison ?&amp;nbsp;&lt;br /&gt;&lt;br /&gt;From what I can find here in the last packet before the peers stopped transmission in a connection event is that the MD (More Data) bit is not set. This means the Peripheral doesn&amp;#39;t want to send anything further.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/1037x616/__key/communityserver-discussions-components-files/4/pastedimage1613730628509v1.png" /&gt;&lt;/p&gt;
&lt;p&gt;There could be 2 reasons for this:&amp;nbsp;&lt;/p&gt;
&lt;p&gt;- There is no data queued. We need to take a look at how you queued your data, have you queued more data when you receive&amp;nbsp;BLE_GATTS_EVT_HVN_TX_COMPLETE event ?&amp;nbsp;&lt;br /&gt;- Your event length configuration was too short. Could you please check&amp;nbsp;NRF_SDH_BLE_GAP_EVENT_LENGTH configuration in sdk_config.h and check if you used that number in&amp;nbsp;nrf_sdh_ble_default_cfg_set()&amp;nbsp; ?&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/295280?ContentTypeID=1</link><pubDate>Fri, 19 Feb 2021 09:24:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ab08c18-a5bd-483c-90e0-d28138c249fe</guid><dc:creator>plippo</dc:creator><description>&lt;p&gt;Hi,&lt;br /&gt;&lt;br /&gt;Sniffing revealed a couple of things. &lt;strong&gt;First, the DLE is now correct so the removal of nrf_ble_gatt module cured that issue.&lt;/strong&gt; Unfortunately that didn&amp;#39;t help the speed as seen in the previous message.&lt;br /&gt;&lt;br /&gt;I&amp;#39;ve attached the screen-grabs from Ellisys which reveal the following:&lt;br /&gt;&lt;br /&gt;Last connection update before data transfer sets the parameters as:&lt;br /&gt;- Transmit window size: 1.250 ms&lt;br /&gt;- Transmit window offset: 18.750 ms&lt;br /&gt;- Connection Event Interval: 45.000 ms&lt;br /&gt;(I could not find Event Length parameter anywhere).&amp;nbsp;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/PHY_5F00_2M_5F00_conn_5F00_update.png" /&gt;&lt;br /&gt;The data transmit happens with correct PHY (2M) and data length (165) but for some reason the transmission only happens for ~10 ms of the whole 45 ms connection interval, the rest is spent waiting.&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/PHY_5F00_2M_5F00_data_5F00_xfer.png" /&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;When having 1M PHY the transmission happens over almost all connection interval (see pic) which explains the throughput difference now that DLE issue has been resolved.&lt;br /&gt;&lt;br /&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/PHY_5F00_1M_5F00_data_5F00_xfer.png" /&gt;&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve attached also here the raw 2M sniffer log in case your experts can use it to figure out the reason for packets not being sent:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/PHY_5F00_2M_5F00_DLEIssue.btt"&gt;devzone.nordicsemi.com/.../PHY_5F00_2M_5F00_DLEIssue.btt&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/295029?ContentTypeID=1</link><pubDate>Thu, 18 Feb 2021 09:41:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e001d489-6287-4880-8816-806c261b7ecd</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Petri,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Please provide the sniffer trace. We would need to see why the throughput dropped. As you mentioned in your last reply the max TX octets remains at 165. So why the throughput dropped ? Was it because the transmitting rate dropped ? or smaller packet was sent even though the DLE TX is 165 ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/294982?ContentTypeID=1</link><pubDate>Thu, 18 Feb 2021 07:00:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5dd70225-552b-42a9-9e4f-efe6ca314f6b</guid><dc:creator>plippo</dc:creator><description>&lt;p&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;I&amp;#39;m away from the sniffer and managed to distill the case to the minimal change of calling or not calling the&amp;nbsp;&lt;em&gt;sd_ble_gap_phy_update()-&lt;/em&gt;function after receiving BLE_GAP_EVT_CONNECTED.&amp;nbsp; The code calls&amp;nbsp;&lt;em&gt;sd_ble_gap_data_length_update()&lt;/em&gt; after receiving BLE_GATTC_EVT_EXCHANGE_MTU_RSP as well as&amp;nbsp;BLE_GAP_EVT_PHY_UPDATE (when status == 0). The row with&amp;nbsp;&lt;em&gt;DataLengthSet&amp;nbsp;&lt;/em&gt;is the one where the call to&amp;nbsp;&lt;em&gt;sd_ble_gap_data_length_update&amp;nbsp;&lt;/em&gt;happens.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;With PHY 2M:&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;00:00:14 BLE GAP: onConnect to 7A:A7:A8:35:1E:5C (Random private resolvable)&lt;br /&gt;00:00:15 BLE event: 0x3A - Exchange MTU Response event&lt;br /&gt;00:00:15 BLE_GATTC_EVT_EXCHANGE_MTU_RSP server_rx_mtu: 161&lt;br /&gt;00:00:15 BleGapService::DataLengthSet&lt;br /&gt;00:00:15 BLE event: 0x22 - BLE_GAP_EVT_PHY_UPDATE&lt;br /&gt;00:00:15 BLE_GAP_EVT_PHY_UPDATE (RX:2, TX:2, status:0)&lt;br /&gt;00:00:15 BleGapService::DataLengthSet&lt;br /&gt;00:00:15 BLE event: 0x24 - Data length update&lt;br /&gt;00:00:15 BLE_GAP_EVT_DATA_LENGTH_UPDATE: max_tx_octets: 165, max_rx_octets: 27&lt;br /&gt;00:00:15 BLE event: 0x12 - Connection Parameters updated&lt;br /&gt;00:00:15 BLE_GAP_EVT_CONN_PARAM_UPDATE. min_conn_interval: 6, max_conn_interval: 6, slave_latency: 0, conn_sup_timeout: 500&lt;br /&gt;00:00:16 BLE event: 0x12 - Connection Parameters updated&lt;br /&gt;00:00:16 BLE_GAP_EVT_CONN_PARAM_UPDATE. min_conn_interval: 36, max_conn_interval: 36, slave_latency: 0, conn_sup_timeout: 500&lt;br /&gt;&lt;br /&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;Same code &lt;strong&gt;without requesting phy_update&lt;/strong&gt;&amp;nbsp;(so the speed stays PHY_1M):&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;00:00:05 BLE GAP: onConnect to 42:B6:5F:10:19:CC (Random private resolvable)&lt;br /&gt;00:00:05 BLE event: 0x3A - Exchange MTU Response event&lt;br /&gt;00:00:05 BLE_GATTC_EVT_EXCHANGE_MTU_RSP server_rx_mtu: 161&lt;br /&gt;00:00:05 BleGapService::DataLengthSet&lt;br /&gt;00:00:05 BLE event: 0x24 - Data length update&lt;br /&gt;00:00:05 BLE_GAP_EVT_DATA_LENGTH_UPDATE: max_tx_octets: 165, max_rx_octets: 27&lt;br /&gt;00:00:06 BLE event: 0x12 - Connection Parameters updated&lt;br /&gt;00:00:06 BLE_GAP_EVT_CONN_PARAM_UPDATE. min_conn_interval: 6, max_conn_interval: 6, slave_latency: 0, conn_sup_timeout: 500&lt;br /&gt;00:00:06 BLE event: 0x12 - Connection Parameters updated&lt;br /&gt;00:00:06 BLE_GAP_EVT_CONN_PARAM_UPDATE. min_conn_interval: 36, max_conn_interval: 36, slave_latency: 0, conn_sup_timeout: 500&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="font-family:&amp;#39;courier new&amp;#39;, courier;"&gt;&lt;span style="font-family:arial, helvetica, sans-serif;"&gt;In both cases I receive the event &lt;span&gt;BLE_GAP_EVT_DATA_LENGTH_UPDATE (max_tx_octets: 165, max_rx_octets: 27) indicating that the DLE is setup identically but the xfer speed is half of 1M case (I&amp;#39;m not with the sniffer right now so I can&amp;#39;t confirm it with it).&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;strong&gt;EDIT:&amp;nbsp;&lt;/strong&gt;I confirmed same behavior with two different phones: OnePlus 8 (Android 11) and Sony XPeria XZ Premium (Android 9) so it does not feel like a phone quirk.&lt;/span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: DLE goes to 27 when using PHY_2M</title><link>https://devzone.nordicsemi.com/thread/294910?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2021 15:12:27 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3cf50ee-cc0f-42b0-a71a-267f33dac3ad</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Petri,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You can move this thread to Private if you want to provide confidential information. Please click on &amp;quot;Go Private&amp;quot; button.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the sniffer trace, please check for which side send the request to change the DLE size.&amp;nbsp;&lt;br /&gt;&lt;br /&gt;It could be the issue on the phone that it doesn&amp;#39;t support long DLE size on 2Mbps PHY.&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>