<?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>What cause the empty PDU</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/103582/what-cause-the-empty-pdu</link><description>Dear Support Team 
 I use the nRF5 SDK&amp;#39;s ble_app_uart_c sample and ble_app_uart sample to test peripheral send data to central. On the application layer, I called ble_nus_data_send() founction to send one packet which 10bytes per 20ms and the BLE connection</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 12 Sep 2023 07:45:05 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/103582/what-cause-the-empty-pdu" /><item><title>RE: What cause the empty PDU</title><link>https://devzone.nordicsemi.com/thread/445540?ContentTypeID=1</link><pubDate>Tue, 12 Sep 2023 07:45:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:0dadb415-c31c-4c9e-9feb-315a446c1324</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;The problem is the flag &amp;quot;SEND_RDY&amp;quot;, where it is reset and set for each BLE_GATTS_EVT_HVN_TX_COMPLETE evt.&lt;/p&gt;
&lt;p&gt;You can for instance move the SEND_RDY=0 to the BLE_GAP_EVT_DISCONNECT event.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What cause the empty PDU</title><link>https://devzone.nordicsemi.com/thread/445507?ContentTypeID=1</link><pubDate>Tue, 12 Sep 2023 02:29:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:51334304-ec28-4b20-8a87-8cee70f6e9d7</guid><dc:creator>Tom.Fu</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;&lt;span&gt;H&amp;aring;ko&lt;/span&gt;&lt;span&gt;n&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Many thanks for the detail explanation.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Is there any other way to avoid or reduce the empty PDU in some connection? In our application, we would like to send 10bytes a packet to the peer every 20ms &lt;strong&gt;accurately&lt;/strong&gt; to control the motor, and the connection interval I set is 20ms, so it requires that a packet must be sent in every connection. Is there any way to achieve this? Many thanks.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What cause the empty PDU</title><link>https://devzone.nordicsemi.com/thread/445412?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2023 12:21:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a9d13dda-99fa-40ec-b4c1-8a73f88e475c</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Sorry for not seeing this earlier, but the SEND_RDY flag is the reason why you&amp;#39;re seeing every other payload.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;When your function is called, you are effectively queueing one payload to the SoftDevice, and for an ACK (ie. evt BLE_NUS_EVT_TX_RDY occurs, which sets SEND_RDY=1 again), that will happen when a notification has completed.&lt;/p&gt;
&lt;p&gt;When receiving GATT event &amp;quot;BLE_GATTS_EVT_HVN_TX_COMPLETE&amp;quot;, which is the same as&amp;nbsp;&lt;span&gt;BLE_NUS_EVT_TX_RDY, it means that the TX has successfully occurred. This comes with a count field, which shows how many packets has been successfully sent in this specific interval, as described by my colleague here:&amp;nbsp;&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/56685/missing-ble_gatts_evt_hvn_tx_complete-events/229610"&gt;RE: Missing BLE_GATTS_EVT_HVN_TX_COMPLETE events&lt;/a&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Kind regards,&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Håkon&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What cause the empty PDU</title><link>https://devzone.nordicsemi.com/thread/445354?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2023 09:52:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a3a1957b-09b2-4dd7-9618-e24c034c8115</guid><dc:creator>Tom.Fu</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi&amp;nbsp;H&amp;aring;kon&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I set&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_GAP_DATA_LENGTH to 27 and the&amp;nbsp;APP_TIMER_CONFIG_RTC_FREQUENCY&amp;nbsp;to 0　and I tried sending data in the ways separately like the screenshot below. But it still catch the empty PDU like before.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1694425865132v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1694425958709v2.png" alt=" " /&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What cause the empty PDU</title><link>https://devzone.nordicsemi.com/thread/445341?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2023 09:20:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b675eab9-0555-4021-88f3-2d6392188e83</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;It depends on if you want to send as much as possible or not.&lt;/p&gt;
&lt;p&gt;It is up to you how you want it to behave.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What cause the empty PDU</title><link>https://devzone.nordicsemi.com/thread/445336?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2023 09:13:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:494881b5-f586-4120-b978-54e18b492827</guid><dc:creator>Tom.Fu</dc:creator><description>&lt;p&gt;&lt;span&gt;Hi&amp;nbsp;H&amp;aring;kon&lt;/span&gt;&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Many thanks for your supporting.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1694423260739v1.png" alt=" " /&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But this part is the sample implementation by default. By the way, what is the correct way to call the&amp;nbsp;ble_nus_data_send() in this case? Many thanks.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What cause the empty PDU</title><link>https://devzone.nordicsemi.com/thread/445332?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2023 09:02:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6a5f8bbd-3892-4e18-a427-d80702c726ec</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Thanks for sharing.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think you want the do-while to be checked with this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;do {
...
} while (err_code != NRF_ERROR_RESOURCES);&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;You should also set sdk_config.h::NRF_SDH_BLE_GAP_DATA_LENGTH to 27 or higher. It was set to 23 by default.&lt;/p&gt;
&lt;p&gt;To send more packets per connection interval, you can also consider adjusting sdk_config.h::NRF_SDH_BLE_GAP_EVENT_LENGTH to a higher number.&lt;/p&gt;
&lt;p&gt;The 40 ms comes from the RTC prescaler. You should set the sdk_config.h::APP_TIMER_CONFIG_RTC_FREQUENCY to &amp;#39;0&amp;#39; to fix this.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Here&amp;#39;s a small screenshot from the sniffer after making the adjustments above:&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1694422925243v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What cause the empty PDU</title><link>https://devzone.nordicsemi.com/thread/445269?ContentTypeID=1</link><pubDate>Mon, 11 Sep 2023 02:31:33 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea518e8f-d4a0-4cab-ad7a-396ddb33d79a</guid><dc:creator>Tom.Fu</dc:creator><description>&lt;p&gt;Hi&amp;nbsp;H&amp;aring;kon&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Sorry for that, I upload the peripheral code again.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;But I found that the NRF_LOG_DEFERRED has been set to 1 both in these two sample by default.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Many thanks.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/1067.ble_5F00_app_5F00_uart.7z"&gt;devzone.nordicsemi.com/.../1067.ble_5F00_app_5F00_uart.7z&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: What cause the empty PDU</title><link>https://devzone.nordicsemi.com/thread/445144?ContentTypeID=1</link><pubDate>Fri, 08 Sep 2023 12:43:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3891bac1-5499-4147-bb70-96c36e8a22cf</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Unfortunately, it seems that the peripheral code was not uploaded properly. Could you please re-upload this?&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Without having tested or looked deeper into the implementation, I would recommend that you use deferred logging, as logging in the handler will delay the function.&lt;/p&gt;
&lt;p&gt;Either set sdk_config.h::NRF_LOG_DEFERRED to 1, or try to limit log printing in your callback handler to see if this has an impact on the behavior.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>