<?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>Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/51000/unexpected-return-value-when-calling-sd_ble_gatts_hvx-when-notifications-are-not-enabled</link><description>This issue concerns code using Softdevice S132 v6.1.1. v5.0.0. I did not test with any other version. 
 From the documentation of sd_ble_gatts_hvx in ble_gatts.h, I expect that the return value when calling this function while notifications are disabled</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 29 Oct 2019 07:47:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/51000/unexpected-return-value-when-calling-sd_ble_gatts_hvx-when-notifications-are-not-enabled" /><item><title>RE: Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled</title><link>https://devzone.nordicsemi.com/thread/217244?ContentTypeID=1</link><pubDate>Tue, 29 Oct 2019 07:47:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bec004ef-9196-4d5a-8fc2-13dabf51aba4</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;The error you see is not BLE_ERROR_NOT_ENABLED, but BLE_ERROR_GATTS_SYS_ATTR_MISSING.&lt;/p&gt;
&lt;p&gt;We can first take a look at the math for the two different definitions:&lt;/p&gt;
&lt;p&gt;&lt;em&gt;NRF_ERROR_STK_BASE_NUM&lt;/em&gt; = 0x3000 in the SDK&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;BLE_ERROR_NOT_ENABLED&lt;/strong&gt; = &lt;em&gt;NRF_ERROR_STK_BASE_NUM &lt;/em&gt;+ &lt;em&gt;0x001&lt;/em&gt; = &lt;strong&gt;0x3001&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;BLE_ERROR_GATTS_SYS_ATTR_MISSING&lt;/strong&gt; = &lt;em&gt;NRF_GATTS_ERR_BASE&lt;/em&gt; + &lt;em&gt;0x001&lt;/em&gt; = &lt;em&gt;NRF_ERROR_STK_BASE_NUM&lt;/em&gt; &lt;em&gt;+ 0x400 + 0x001&lt;/em&gt; = &lt;strong&gt;0x3401&lt;/strong&gt;&lt;/p&gt;
&lt;p&gt;Also checked that this is the value by debugging:&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/836x243/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-5dfd9481612d4739b8480e3fe3fce6f2/pastedimage1572334871191v2.png" /&gt;&lt;/p&gt;
&lt;p&gt;Can also see that sd_ble_enabled returns 0x8 which is invalid state (NRF_ERROR_INVALID_STATE):&lt;/p&gt;
&lt;p&gt;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/828x189/__key/support-attachments/beef5d1b77644c448dabff31668f3a47-5dfd9481612d4739b8480e3fe3fce6f2/pastedimage1572334990345v3.png" /&gt;&lt;/p&gt;
&lt;p&gt;So I&amp;#39;m pretty confident that the error is BLE_ERROR_GATTS_SYS_ATTR_MISSING, and the solution to handle this error is described &lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/20420/ble-app-blinky-ble_error_gatts_sys_attr_missing/79617#79617"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled</title><link>https://devzone.nordicsemi.com/thread/217112?ContentTypeID=1</link><pubDate>Mon, 28 Oct 2019 13:58:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3ea673e3-bb0f-41a5-8bfc-7d8e925e57b0</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;I&amp;#39;ve give you a reply tomorrow, I&amp;#39;ve been quite busy today, sorry.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled</title><link>https://devzone.nordicsemi.com/thread/216856?ContentTypeID=1</link><pubDate>Fri, 25 Oct 2019 12:57:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:47624c83-853e-4865-bc21-d48ee7a47c6b</guid><dc:creator>m.wagner</dc:creator><description>&lt;p&gt;Hi Andreas,&lt;/p&gt;
[quote userid="73423" url="~/f/nordic-q-a/51000/unexpected-return-value-when-calling-sd_ble_gatts_hvx-when-notifications-are-not-enabled/204278"]Could you help me reproduce the issue? Perhaps share your project? I can make the ticket private if you like :-) [/quote]
&lt;p&gt;I finally managed to reproduce the issue for you. I don&amp;#39;t even have to provide code, the Nordic SDK provides the example directly.&lt;/p&gt;
&lt;p&gt;&lt;strong&gt;Steps to reproduce:&lt;/strong&gt;&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;Download SDK 15.2.0&lt;/li&gt;
&lt;li&gt;Flash the associated softdevice onto an nRF52 DK (S132 v6.1.0)&lt;/li&gt;
&lt;li&gt;Build and flash the exmple &amp;quot;ble_peripheral\ble_app_blinky&amp;quot;&lt;/li&gt;
&lt;li&gt;Start the debugger and set a breakpoint in main.c, function &lt;em&gt;button_event_handler(), &lt;/em&gt;in&lt;em&gt; &lt;/em&gt;the if-block on line 497:&lt;br /&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;if (err_code != NRF_SUCCESS &amp;amp;&amp;amp;
                err_code != BLE_ERROR_INVALID_CONN_HANDLE &amp;amp;&amp;amp;
                err_code != NRF_ERROR_INVALID_STATE &amp;amp;&amp;amp;
                err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)&lt;/pre&gt;&lt;/li&gt;
&lt;li&gt;Connect to the peripheral with e.g. nRF Connect.&lt;/li&gt;
&lt;li&gt;Press Button 1 on the nRF52 DK.&lt;/li&gt;
&lt;li&gt;When you inspect the contents of the err_code variable in the debugger, you will notice that the value reads&lt;em&gt; 0x3401&lt;/em&gt;, which corresponds to &lt;em&gt;BLE_ERROR_NOT_ENABLED &lt;/em&gt;and is documented in ble_err.h as indicating that&lt;em&gt; &amp;quot;sd_ble_enable has not been called.&amp;quot;&lt;/em&gt;&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;-mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled</title><link>https://devzone.nordicsemi.com/thread/205337?ContentTypeID=1</link><pubDate>Wed, 21 Aug 2019 13:18:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2ae2d71f-8374-4036-a3a9-72b9289e5002</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;It&amp;#39;s the same check performed for v6.1.1 as for v5.0.0, so it should not be different as far as I know.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled</title><link>https://devzone.nordicsemi.com/thread/205325?ContentTypeID=1</link><pubDate>Wed, 21 Aug 2019 12:49:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dd5398ed-b375-42da-8953-32f6bc854eca</guid><dc:creator>m.wagner</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Unfortunately I haven&amp;#39;t gotten around looking into it more closely, but I noticed that I mixed up two projects. This issue specifically concerns S132 v5.0.0 and not v6.1.1 as originally mentioned!&lt;/p&gt;
&lt;p&gt;Also, the product has actually been in production for some time and is not still in development.&lt;/p&gt;
&lt;p&gt;Regards,&lt;/p&gt;
&lt;p&gt;-mike&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled</title><link>https://devzone.nordicsemi.com/thread/204278?ContentTypeID=1</link><pubDate>Thu, 15 Aug 2019 11:12:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:94d80355-e7fa-4428-a862-f176ebc4c0e9</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Could you help me reproduce the issue? Perhaps share your project? I can make the ticket private if you like :-) &lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled</title><link>https://devzone.nordicsemi.com/thread/204248?ContentTypeID=1</link><pubDate>Thu, 15 Aug 2019 09:09:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d9504153-c2b8-4cc2-8337-0ee9fac9452a</guid><dc:creator>m.wagner</dc:creator><description>[quote userid="73423" url="~/f/nordic-q-a/51000/unexpected-return-value-when-calling-sd_ble_gatts_hvx-when-notifications-are-not-enabled/204197"]Have you enabled the SoftDevice?[/quote]
&lt;p&gt;As I mentioned in my initial question, the softdevice is enabled. Even a BLE connection has been established at the point that issue arises, so the behaviour of this call is indeed not as documented.&lt;/p&gt;
&lt;p&gt;I just assume that there was a simple mishap when implementing the function, &amp;quot;BLE_ERROR_NOT_ENABLED&amp;quot; by itself does sound like the right error to return when notifications are &amp;quot;not enabled&amp;quot;... ;-)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unexpected return value when calling sd_ble_gatts_hvx() when notifications are not enabled</title><link>https://devzone.nordicsemi.com/thread/204197?ContentTypeID=1</link><pubDate>Thu, 15 Aug 2019 06:57:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50f3f557-7dd4-45fe-90aa-ec74a74203a6</guid><dc:creator>AndreasF</dc:creator><description>&lt;p&gt;Hi.&lt;/p&gt;
&lt;p&gt;Have you enabled the SoftDevice? &lt;code&gt;BLE_ERROR_NOT_ENABLED&lt;/code&gt; will only be returned if the SoftDevice is not enabled.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Andreas&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>