<?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>Does sd_ble_gatts_hvx use a dedicated memory pool?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/79246/does-sd_ble_gatts_hvx-use-a-dedicated-memory-pool</link><description>Hello, 
 Our Peripheral server application regularly uses a stream of notifications to transmit data to a Central client. We have a rare error in which sd_ble_gatts_hvx returns NRF_ERROR_RESOURCES. The interesting part is that this appears be correlated</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 06 Sep 2021 13:19:09 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/79246/does-sd_ble_gatts_hvx-use-a-dedicated-memory-pool" /><item><title>RE: Does sd_ble_gatts_hvx use a dedicated memory pool?</title><link>https://devzone.nordicsemi.com/thread/328212?ContentTypeID=1</link><pubDate>Mon, 06 Sep 2021 13:19:09 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e78203f8-0825-49df-8ad1-e7430886ad8b</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;I checked this with the SoftDevice team, and my earlier statement was not entirely correct. There is a dedicated HVN queue, and that is 1 by default. There are also more shared LL buffers,&amp;nbsp; so you can typically schedule more packets, depending on configuration. These can be used for any type of packet. To reserve buffers for more than 1 notification you need to configure it with&amp;nbsp;BLE_CONN_CFG_GATTS (ble_gatts_conn_cfg_t::hvn_tx_queue_size).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does sd_ble_gatts_hvx use a dedicated memory pool?</title><link>https://devzone.nordicsemi.com/thread/328019?ContentTypeID=1</link><pubDate>Fri, 03 Sep 2021 16:04:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2a50a123-dd53-49a3-a8cc-bd2f34382416</guid><dc:creator>Elias</dc:creator><description>&lt;p&gt;Yes, I am familiar with&amp;nbsp;everything in the first half of your answer, as I have been working with the Nordic SoftDevice &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/25637/can-you-not-call-sd_ble_gatts_hvx-in-a-loop"&gt;for years&lt;/a&gt;. Our application is built to wait for &lt;span&gt;BLE_GATTS_EVT_HVN_TX_COMPLETE&amp;nbsp;before&lt;/span&gt;&amp;nbsp;ERROR_RESOURCES should occur, and when ERROR_RESOURCES does happen, it is handled gracefully&lt;span&gt;.&amp;nbsp;T&lt;/span&gt;his issue is only interesting because &lt;span&gt;ERROR_RESOURCES&amp;nbsp;really is rare in our system after years of development and months of integration testing; and it&amp;#39;s also correlated with a different error.&lt;/span&gt;&lt;br /&gt;&lt;br /&gt;&amp;gt; &lt;span&gt;It is the same Tx queue for data like this&lt;/span&gt;&lt;span&gt;.&lt;br /&gt;&amp;quot;Data like this&amp;quot;&amp;nbsp;meaning enqueued notifications?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&amp;gt;&amp;nbsp;control packets, reads of characteristics etc are not part of the same queue&lt;br /&gt;This is close to the information I was looking for. Is this a definite statement that there is&amp;nbsp;&lt;em&gt;nothing&lt;/em&gt;&lt;em&gt; else&lt;/em&gt; that take up memory that would otherwise be allocated for the Tx queue by the SoftDevice?&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Does sd_ble_gatts_hvx use a dedicated memory pool?</title><link>https://devzone.nordicsemi.com/thread/327991?ContentTypeID=1</link><pubDate>Fri, 03 Sep 2021 13:28:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f1a6137-b1d4-4cfe-9a67-b0972e875b0d</guid><dc:creator>Einar Thorsrud</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
[quote user=""]ble_gatts.h says that NRF_ERROR_RESOURCES means &amp;quot;Too many notifications queued.&amp;quot; However, we believe we have allocated enough memory for the SoftDevice so that we should never&amp;nbsp;&lt;span&gt;enqueue too many notifications.&lt;/span&gt;[/quote]
&lt;p&gt;It is not possible to queue an infinite number of notifications, they need to be buffered in the SoftDevice memory. The amount of memory set aside by the SoftDevice for this depends on the configuration, for instance event length. (Therefor you can see that you must adjust the application RAM start address if you change these configurations).&lt;/p&gt;
&lt;p&gt;If you queue notifications more quickly than they are sent, then you will get&amp;nbsp;NRF_ERROR_RESOURCES. This will typically happen from time to time in most real applications, for instance if there are a lot of consecutive retransmissions etc. So this is a situation you need to handle in any application. In this case you typically wait for a&amp;nbsp;BLE_GATTS_EVT_HVN_TX_COMPLETE&amp;nbsp; event before you try to queue the notification again.&lt;/p&gt;
[quote user=""]Does the&amp;nbsp;SoftDevice have a portion of its memory pool dedicated to buffering notifications, or does it share the&amp;nbsp;this memory&amp;nbsp;with other events?&amp;nbsp;If the memory pool is shared and fills with &amp;quot;too many&amp;quot; events, what are the symptoms?[/quote]
&lt;p&gt;It is the same Tx queue for data like this (control packets, reads of characteristics etc are not part of the same queue). The symptom is that you get&amp;nbsp;NRF_ERROR_RESOURCES when you attempt to queue a new notification or indication.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>