<?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>sd_ble_gatts_hvx returns 13313 (rarely)</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48189/sd_ble_gatts_hvx-returns-13313-rarely</link><description>Hi, 
 sd_ble_gatts_hvx returns 13313 in some rare cases involving the phone is far from the nrf52840. 
 My questions: 
 1. What this return code means? 
 2. What is the recommended way to recuperate when it happens? 
 3. Is there a way to avoid it? 
</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 08 Oct 2019 09:01:48 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48189/sd_ble_gatts_hvx-returns-13313-rarely" /><item><title>RE: sd_ble_gatts_hvx returns 13313 (rarely)</title><link>https://devzone.nordicsemi.com/thread/213822?ContentTypeID=1</link><pubDate>Tue, 08 Oct 2019 09:01:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8ec426cf-6947-4c48-a0c2-6fa43c492df1</guid><dc:creator>WrightLin.Avnet</dc:creator><description>&lt;p&gt;Hi Andy:&lt;/p&gt;
&lt;p&gt;Sorry to ask here, but do you have any idea about the situation that error code 8 was feedback from&amp;nbsp;&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html?cp=3_4_2_1_2_4_2_11#ga577c788e199b1a2c0d19602b07ef2515"&gt;sd_ble_gatts_sys_attr_set()&lt;/a&gt;&amp;nbsp;in BLE connected event?&amp;nbsp;&lt;span&gt;&amp;nbsp;&amp;nbsp;&lt;br /&gt;&lt;br /&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gatts_hvx returns 13313 (rarely)</title><link>https://devzone.nordicsemi.com/thread/191119?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 12:55:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:8bf9d9b1-0c66-49a5-af50-7b586312d733</guid><dc:creator>Andy</dc:creator><description>&lt;p&gt;What results in error code 8 (invalid state)?&lt;/p&gt;
&lt;p&gt;The documentation is here:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html?cp=3_4_2_1_2_4_2_4#ga313fe43c2e93267da668572e885945db"&gt;sd_ble_gatts_hvx()&lt;/a&gt;&amp;nbsp;and&amp;nbsp;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s140.api.v6.1.1/group___b_l_e___g_a_t_t_s___f_u_n_c_t_i_o_n_s.html?cp=3_4_2_1_2_4_2_11#ga577c788e199b1a2c0d19602b07ef2515"&gt;sd_ble_gatts_sys_attr_set()&lt;/a&gt;.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gatts_hvx returns 13313 (rarely)</title><link>https://devzone.nordicsemi.com/thread/191112?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 12:46:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8af2018-1933-49d6-8d5f-03e8a5816a43</guid><dc:creator>Daniel Reisfeld</dc:creator><description>&lt;p&gt;Andy,&lt;/p&gt;
&lt;p&gt;This results in return code 8.&lt;/p&gt;
&lt;p&gt;I haven&amp;#39;t found relevant documentation.&lt;/p&gt;
&lt;p&gt;Please advise,&lt;/p&gt;
&lt;p&gt;Daniel&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: sd_ble_gatts_hvx returns 13313 (rarely)</title><link>https://devzone.nordicsemi.com/thread/190992?ContentTypeID=1</link><pubDate>Wed, 05 Jun 2019 08:13:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:93d57417-5da2-4d59-9257-b6fd69a3de72</guid><dc:creator>Andy</dc:creator><description>[quote userid="67166" url="~/f/nordic-q-a/48189/sd_ble_gatts_hvx-returns-13313-rarely"]1. What this return code means?[/quote]
&lt;p&gt;It means the system attributes are missing. You can see that in the documentation.&lt;/p&gt;
[quote userid="67166" url="~/f/nordic-q-a/48189/sd_ble_gatts_hvx-returns-13313-rarely"]2. What is the recommended way to recuperate&amp;nbsp;when it happens?[/quote]
&lt;p&gt;Just do this:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;err_code = sd_ble_gatts_hvx(conn_handle, &amp;amp;hvx_params);

if (err_code == BLE_ERROR_GATTS_SYS_ATTR_MISSING) {
	err_code = sd_ble_gatts_sys_attr_set(conn_handle, NULL, 0, 0);
	APP_ERROR_CHECK(err_code);
	
	// Try again
	err_code = sd_ble_gatts_hvx(conn_handle, &amp;amp;hvx_params);
}&lt;/pre&gt;&lt;/p&gt;
[quote userid="67166" url="~/f/nordic-q-a/48189/sd_ble_gatts_hvx-returns-13313-rarely"]3. Is there a way to avoid it?[/quote]
&lt;p&gt;Set the system attributes beforehand.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>