<?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>Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/28274/adding-characteristic-for-purpose-of-long-read-fails</link><description>I&amp;#39;ve added a custom service for transferring data. It shall contain one characteristic that will notify when data is available, and the other should be a long read characteristic (no notify). sd_ble_gatts_characteristic_add is failing (return 0x7) when</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 14 Dec 2017 17:31:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/28274/adding-characteristic-for-purpose-of-long-read-fails" /><item><title>RE: Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/thread/111684?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2017 17:31:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c17f312e-f834-42e1-bb96-7a3a311dd8d1</guid><dc:creator>Aurabindo</dc:creator><description>&lt;p&gt;@hungbui by &amp;quot;send a long sequence of bytes&amp;quot;, I did not specifically mean about setting characteristic&amp;#39;s data or not setting it. Either way it would work fine for me, unless one method has considerable performance penalty in terms of data throughput. Thanks for the suggestion&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/thread/111685?ContentTypeID=1</link><pubDate>Thu, 14 Dec 2017 11:51:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:05407622-658b-4cdd-ae3e-7af7fd95a4e3</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Aurabindo,&lt;/p&gt;
&lt;p&gt;What do you mean by &amp;quot;send a long sequence of bytes&amp;quot; ? Do you mean that you can send different data instead of the value of the characteristic ? If it&amp;#39;s the case, you may need read with authorization, where you can actually set the data you want to set to the characteristic and send it via read response.&lt;/p&gt;
&lt;p&gt;sd_ble_gattc_read() can be used on the client side to do a read. Offset parameter can be used to do a read blob /read long. Meaning you need to do several sd_ble_gattc_read() and move the offset to read the whole characteristic.&lt;/p&gt;
&lt;p&gt;Note that if you use authorization, you can think of updating the characteristic value to send different trunk of data based on the number of read instead of using offset, This is useful when you don&amp;#39;t want to use a large buffer or if the size of your data is bigger than the max size for characteristic (512).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/thread/111682?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2017 18:09:23 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4f12a8ec-e13e-4a72-8a8b-1b55aa9f8991</guid><dc:creator>Aurabindo</dc:creator><description>&lt;p&gt;@hungbui Let me try to clear the misunderstanding. I did look into the message sequence chart. I would like to clarify that my requirement is not to read long characteristic from a peer device. Rather, when a peer device does a read, my device should be able to send a long sequence of bytes. So from your response, I infer that &lt;code&gt;sd_ble_gattc_read()&lt;/code&gt; is used to  do a long read on a peer&amp;#39;s characteristic. Am  I right ?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/thread/111681?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2017 16:38:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9ad16c5f-6612-42af-bd6b-a145f7046172</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;No. Why you talk about GATT client here? we are talking about gatt server.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;It should as it&amp;#39;s defined in BLE_GATTS_VAR_ATTR_LEN_MAX isn&amp;#39;t it.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;&amp;quot;The Client Characteristic Configuration declaration shall be readable and writable.&amp;quot; It&amp;#39;s defined in the spec (section 3.3.3.3 Vol 3 Part G Spec v4.0)&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I don&amp;#39;t understand you. Authorization has nothing to do with long read. Have you looked at the sequence chart I mentioned in the answer ??&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Check the message sequence chart.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;You mean sd_ble_gatts_value_set? This function tells nothing to the peer device, it only update the value of the characteristic. You need to send a notification if you want to tell the peer device you have new data (using sd_ble_gatts_hvx() function). This function take a pointer and length and then update it to the buffer you declare when you initialize the characteristic. The buffer can be inside the stack if you use BLE_GATTS_VLOC_STACK. If you use BLE_GATTS_VLOC_USER, the it will be the buffer you provided as the initialize value of the characteristic.&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/thread/111680?ContentTypeID=1</link><pubDate>Wed, 13 Dec 2017 13:46:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e111df63-4336-4263-8352-c15e960765fe</guid><dc:creator>Aurabindo</dc:creator><description>&lt;p&gt;@hungbui knock knock&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/thread/111679?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2017 18:03:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:105ee8b3-ce54-4eaa-9acc-c8f65b590f45</guid><dc:creator>Aurabindo</dc:creator><description>&lt;ol start="6"&gt;
&lt;li&gt;Inorder to tell the stack that I have fresh data to be sent from the peripheral next time when a read is performed by a peer, the function to be used to set the fresh data is &lt;code&gt;sd_ble_gatts_set_data()&lt;/code&gt; ? If so, this function takes a pointer to data with its length and offset. What significance does it have wrt the data pointer that was initially setup for this characteristic when it was created/added ? Can i point to this same buffer ?&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/thread/111678?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2017 17:51:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fed87166-2dc0-4823-ba2d-a74f68ed5e78</guid><dc:creator>Aurabindo</dc:creator><description>&lt;ol start="4"&gt;
&lt;li&gt;
&lt;p&gt;Even though both read blob and read with authorization are not related, is this not the only way to send to the peer a long read sequence when the peer does a normal read ? My assumption was that I will have to enable read with authorization for this characteristic, and just before I reply, I will have to call the corresponding api that does long read (which turns out to be sd_ble_gattc_read instead of sd_ble_gatts_value_get from your answer). Is this the right way to make a long read happen ?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Is my understanding correct that the peer has only one kind of read; and its the peripheral that decides to do a long/normal read  ?&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/thread/111683?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2017 17:21:50 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:09833eff-42b0-4d12-884b-898205b55408</guid><dc:creator>Aurabindo</dc:creator><description>&lt;p&gt;Thank you for the response @Hung Bui, I have some questions:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;
&lt;p&gt;Are there any other setup necessary to do related to GATT Client during initialization?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Is the value 512 valid for the max length of the characteristic?&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;I&amp;#39;m unable to understand the reason why cccd needs the write permission, when there is no need for a peer to write to it, since it doesnt support enabling notification. Are there other reasons cccd needs to be written ?&lt;/p&gt;
&lt;/li&gt;
&lt;/ol&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Adding characteristic (for purpose of long read) fails</title><link>https://devzone.nordicsemi.com/thread/111677?ContentTypeID=1</link><pubDate>Tue, 12 Dec 2017 16:14:48 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1d87b07e-53a9-4c97-98f0-2ae4a3d75f70</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Aura,&lt;/p&gt;
&lt;p&gt;There is no relation between read blob and read with authorization . Have a look &lt;a href="http://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group___b_l_e___g_a_t_t_c___v_a_l_u_e___r_e_a_d___m_s_c.html?cp=2_3_1_1_0_2_2_3_4"&gt;here&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;The reason you have error #7 is that you don&amp;#39;t set a write permission for CCCD which is required. Try adding this:&lt;/p&gt;
&lt;pre&gt;&lt;code&gt;BLE_GAP_CONN_SEC_MODE_SET_OPEN(&amp;amp;cccd_md.write_perm);
&lt;/code&gt;&lt;/pre&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>