<?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>Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/8732/undocumented-return-codes-for-sd_ble_gatts_value_get</link><description>Hi,
I&amp;#39;m writing a service to send indications on a couple of characteristics that are part of a service. In order to determine whether indications have been enabled or not, I use sd_ble_gatts_value_get to retrieve the cccd value. However, when I attempt</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 14 Aug 2015 11:55:47 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/8732/undocumented-return-codes-for-sd_ble_gatts_value_get" /><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32033?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 11:55:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc1371b7-d02c-4d9e-9367-538d74ff58a1</guid><dc:creator>&amp;#216;yvind R&amp;#248;nningstad</dc:creator><description>&lt;p&gt;The Device Manager calls sd_ble_gatts_sys_attr_set() when encryption is enabled, so when already bonded, you can wait for the DM_EVT_LINK_SECURED event from DM. If the event_result is not DM_SERVICE_CONTEXT_NOT_APPLIED, you should be able to call sd_ble_gatts_value_get() without getting the BLE_ERROR_GATTS_SYS_ATTR_MISSING error code.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32026?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 11:54:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7492851e-a863-4a2d-98bb-75628d32da69</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Indeed - like you I trusted the header files .. I should know better by now :)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32025?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 11:18:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ec423ebe-5b64-47e3-88d6-c13dffa0c6b9</guid><dc:creator>Edweirdo</dc:creator><description>&lt;p&gt;Seems like it wasn&amp;#39;t the softdevice version that was the problem, but thanks for your help!&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32032?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 11:04:04 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:10107fed-b60d-4e54-a83a-9716e84dbe6f</guid><dc:creator>Edweirdo</dc:creator><description>&lt;p&gt;Ok, how do those commands relate to the service context get and set of the device manager? I suspected something like this might be the case and so were experimenting with them before lunch, without much success. I was, however, assuming that the set command would store the information and the get command restore it.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32031?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 10:54:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4e210417-de48-482e-a05f-0f1665c8e9f8</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;you also need to intialize len and p_value of course&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32030?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 10:52:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b3454666-c369-489d-9f06-90688193fd16</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;about the INVALID_PARAM return code: I notice you are not setting ble_gatts_value_t::offset to 0 before you call sd_ble_gatts_value_get(). If you do that you should no longer get that error code. This is an input structure, and so all its members must be initialized to valid values.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32029?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 10:50:14 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:020adcea-dd93-4bb2-9b49-f1edaf2fe38a</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Yes you are missing the fact that once bonded, it is the app&amp;#39;s (or the DM&amp;#39;s) responsibility to store the last state of all CCCDs using sd_ble_gatts_sys_attr_get() and then restoring them on reconnection with sd_ble_gatts_sys_attr_set(). Then you wouldn&amp;#39;t have to wait for anything, since having restored them you would know that they&amp;#39;re immediately in the same exact state they were left in after the last disconnection. By waiting for the peer to enable them again you might run into an endless wait, since the peer will assume that you have restored their last value according to the spec&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32028?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 10:47:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bb146e81-2378-4365-adb3-916e591a4da4</guid><dc:creator>Edweirdo</dc:creator><description>&lt;p&gt;Waiting for the write event was my original solution, but I ran into problems on successive connects with a bonded device - as the indications were already enabled, no new write was made. I then decided to switch to actually reading the value, but ran into the aforementioned problems.&lt;/p&gt;
&lt;p&gt;Currently I&amp;#39;m simply attempting to indicate using the sd_ble_gatts_hvx() function, and waiting for it to return something other than NRF_ERROR_INVALID_STATE. This works fine, apart from the fact that when I reconnect it seems that the cccds have been reset to indications disabled, but the phone app considers them enabled. I&amp;#39;m guessing I&amp;#39;m missing something in the device manager, but so far I haven&amp;#39;t figured out what.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32027?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 09:51:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:df5dc463-83ca-444a-bb20-771a781de43e</guid><dc:creator>Carles</dc:creator><description>&lt;p&gt;Hi there,&lt;/p&gt;
&lt;p&gt;First of all, if you want to know whether indications have been enabled or not, I would recommend instead waiting for the BLE_GATTS_EVT_WRITE event the first time you connect and then, if you bond, you should be ready to indicate the moment you call sd_ble_gatts_sys_attr_set().&lt;/p&gt;
&lt;p&gt;Regarding the undocumented error codes, I have created an internal issue. I still don&amp;#39;t see how you can get INVALID_PARAM, but SYS_ATTR_MISSING will be added to the documentation.&lt;/p&gt;
&lt;p&gt;Carles&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32024?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 09:25:16 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3105f230-05d4-46c6-8c47-5a284ae4785f</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;I believe that&amp;#39;s ok - SDK8 and SDK9 both use SD8.0 and yes it really is confusing sometimes. I&amp;#39;m just at a bit of a loss how you are getting those returns from functions which don&amp;#39;t return them, and the only sd function I can find which does is the hvx() one, which is a bit suspicious.&lt;/p&gt;
&lt;p&gt;try a clean build and double triple check you have the right softdevice, 8.0, on the chip. At that point I&amp;#39;m out of ideas.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32023?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 09:13:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dfa4a2c0-2f0b-4f02-aca3-75b232bb8c8f</guid><dc:creator>Edweirdo</dc:creator><description>&lt;p&gt;How would I verify that? I&amp;#39;ve used the ble_app_template to base things off of, and I&amp;#39;ve checked that the proper preprocessor symbols (S110 and SOFTDEVICE_PRESENT) are defined for the selected project, which is according to its name based on the S110 (ble_app_template_s110_pca10028 - nrf51422_xxac_s110). The one oddity is the S110&amp;#39;s own version numbering, which, although I got it from the nRF51_SDK_8.1.0, in nRFgo studio has the version number 8.0.0. Could that be the problem? A mistaken call sounds like a very probable explanation to why I&amp;#39;m getting these odd return values, but shouldn&amp;#39;t I also get an erronous response from sd_ble_gatts_hvx? The latter seems to be working perfectly, apart from the fact that when I reconnect I get an invalid state response although the master control panel in my phone insists that indications are enabled.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32022?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 08:42:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:340d555b-cb00-46da-b30a-b9cdfbbf0626</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;Are you compiling with header files which match the softdevice you&amp;#39;re using? The SVC call number for sd_ble_gatts_value_get() is only one different from that for sd_ble_gatts_hvx() which does return both those error codes. A mismatch between softdevice headers and actual softdevice could explain that.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32021?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 08:23:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2dcecaf-3f22-4de8-ad5f-f0e04cca3f43</guid><dc:creator>Edweirdo</dc:creator><description>&lt;p&gt;The value I get for BLE_ERROR_GATTS_SYS_ATTR_MISSING is 13313, which is the same as I get when I print that constant. The value I get for NRF_ERROR_INVALID_PARAM is 7, also the same as when I print that constant. However, I had some problems recreating the latter error, it doesn&amp;#39;t seem tied to bonding as I first believed. When I ran it just now I merely got it once, just before completing indication on the last characteristic and disconnecting. Could it be some sort of memory accessing error? I&amp;#39;m overwriting the return code? I&amp;#39;ve added the code snippet in question to the original post.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Undocumented return codes for sd_ble_gatts_value_get()</title><link>https://devzone.nordicsemi.com/thread/32020?ContentTypeID=1</link><pubDate>Fri, 14 Aug 2015 08:08:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:029566e7-dcec-4e74-adcb-08c5139625fb</guid><dc:creator>RK</dc:creator><description>&lt;p&gt;They aren&amp;#39;t possible return values from that function. You are actually getting those result codes from the call to sd_ble_gatts_value_get()? Can you post those error codes as hex or decimal just to be sure they are the ones you&amp;#39;re talking about.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>