<?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>How to read and write long string?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/3586/how-to-read-and-write-long-string</link><description>I have a characteristic which is a long string. I need to be able to read and write it. 
 Below is the function for writing to start with. Please comment on this function. The guesswork it has is inverse proportional to my level of BLE expertise(very</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 28 Aug 2014 09:28:02 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/3586/how-to-read-and-write-long-string" /><item><title>RE: How to read and write long string?</title><link>https://devzone.nordicsemi.com/thread/12994?ContentTypeID=1</link><pubDate>Thu, 28 Aug 2014 09:28:02 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b0a1950-8a1c-48a1-8c62-d7961828fa0b</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Barmaley,
I updated the answer with attached example.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read and write long string?</title><link>https://devzone.nordicsemi.com/thread/12993?ContentTypeID=1</link><pubDate>Wed, 27 Aug 2014 13:48:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2319d967-417d-4e2e-bbe6-c7d732083725</guid><dc:creator>barmaley</dc:creator><description>&lt;p&gt;Thank you for your quick reply. Will try to get deeper into it. Could you please provide examples of using supported long write and long read.
Thanks again,&lt;/p&gt;
&lt;p&gt;Bar&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read and write long string?</title><link>https://devzone.nordicsemi.com/thread/12992?ContentTypeID=1</link><pubDate>Wed, 27 Aug 2014 13:39:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9498c9a1-b98b-4431-b9f1-4f91a9466286</guid><dc:creator>Hung Bui</dc:creator><description>&lt;p&gt;Hi Barmaley,&lt;/p&gt;
&lt;p&gt;Your code is not &amp;quot;long write&amp;quot; as in the thread title, it&amp;#39;s notification.&lt;/p&gt;
&lt;p&gt;Currently we do support long write and long read from S110 v5.x. However, notification is not. I don&amp;#39;t think notify long is even described in the Bluetooth spec. If you notify a long characteristic, only the first 20 bytes is sent.&lt;/p&gt;
&lt;p&gt;So, you have three option:&lt;/p&gt;
&lt;ul&gt;
&lt;li&gt;
&lt;p&gt;Notify the first 20 bytes, and then use the client (the peer device) to do a read long, you should get the value of the long characteristics with that.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Create a server on the peer device, and do a write long from the S110 (client) to the server, instead of notifying.&lt;/p&gt;
&lt;/li&gt;
&lt;li&gt;
&lt;p&gt;Use what you are doing now. Split the long data into 20 bytes trunk and then collect and join them on the peer device.&lt;/p&gt;
&lt;/li&gt;
&lt;/ul&gt;
&lt;p&gt;On thing I noticed from your code is that you will break when sd_ble_gatts_hvx() doesn&amp;#39;t return NRF_SUCCESS. However, there is a case that the buffer is full. And it will, since the buffer is only 7 slots. You may want to wait when you receive BLE_ERROR_NO_TX_BUFFERS, and continue to send (from the point you receive buffer full) when you get BLE_EVT_TX_COMPLETE event which mean one or more slot in the buffer is free.&lt;/p&gt;
&lt;p&gt;I attached here an example of a long characteristics (HRM value). This will support a long write and long read from the client. You can test read long and write long using Master Control panel v3.6. The example should be compiled with SDK v5.2 and S110 v6.0.&lt;/p&gt;
&lt;p&gt;Regarding the example to do a long write from nRF51 as a client, unfortunately we currently don&amp;#39;t have one. But it is supported. &lt;a href="https://devzone.nordicsemi.com/cfs-file/__key/communityserver-discussions-components-files/4/ble_5F00_app_5F00_hrs-_2D00_-LongChar.zip"&gt;ble_app_hrs - LongChar.zip&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to read and write long string?</title><link>https://devzone.nordicsemi.com/thread/12991?ContentTypeID=1</link><pubDate>Tue, 26 Aug 2014 12:15:59 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:82f61a83-b5f5-46de-936c-8e8e5b49812c</guid><dc:creator>barmaley</dc:creator><description>&lt;p&gt;I don&amp;#39;t think that nobody needs nor uses long data. I read &lt;a href="https://devzone.nordicsemi.com/question/1741/dealing-large-data-packets-through-ble/"&gt;this&lt;/a&gt;. Not exactly clear though.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>