<?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>Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/27226/unable-to-receive-full-data-over-ble</link><description>I am trying to receive a string of 708 characters via BLE. As BLE cap a maximum of 20 bytes per transmission, at the mobile app side I break the data to be send every 20 characters (each char is 1 byte as &amp;lt; 7F). The code at Nordic to receive the data</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 24 Nov 2017 11:33:53 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/27226/unable-to-receive-full-data-over-ble" /><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107414?ContentTypeID=1</link><pubDate>Fri, 24 Nov 2017 11:33:53 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:118038c4-4457-46a0-87e0-e438125755ea</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;I agree with endnode that you definitely should not use malloc/realloc &amp;amp; instead use a global static buffer. @jj Also, have you tried to use a sniffer yet like Torsten suggests below? Do you know how many packets your nrf52 receives?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107413?ContentTypeID=1</link><pubDate>Wed, 22 Nov 2017 12:40:05 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:54ec5655-fa19-4cd4-8d1c-170d5b7012d0</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;Would you mind sending me your code in a private message?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107411?ContentTypeID=1</link><pubDate>Fri, 17 Nov 2017 01:46:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bed46e61-385e-40f7-a296-c5fd90021815</guid><dc:creator>jj</dc:creator><description>&lt;p&gt;Hi, it is still not working. Any suggestions?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107415?ContentTypeID=1</link><pubDate>Wed, 15 Nov 2017 12:12:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:de96ecc7-437d-4da7-be1f-004ba666ee79</guid><dc:creator>Bj&amp;#248;rn Kvaale</dc:creator><description>&lt;p&gt;Hi jj, what is the status of this issue? Have you figured it out or is it still not working?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107407?ContentTypeID=1</link><pubDate>Fri, 10 Nov 2017 01:07:30 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:6f987963-4e70-4c4e-8b3b-9172d8b84a0b</guid><dc:creator>jj</dc:creator><description>&lt;p&gt;I changed the data to transmit over, which now consist of 536 characters. Currently, up till total_len of 480, Nordic is able to receive all of the data at &lt;code&gt;buf&lt;/code&gt; and print out at SEGGER_RTT. But once it receives the next round of data (total_len of 500), printing &lt;code&gt;buf&lt;/code&gt; will only contain the data up till 429th character. Subsequently, &lt;code&gt;buf&lt;/code&gt; will always print out 0-429th character only. This is really strange, as it did managed to receive more than 429 previously and stored in &lt;code&gt;buf&lt;/code&gt;, but all of a sudden those data disappear and only 0-429th characters remain. This happens for both static and dynamic buffer allocation.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107412?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2017 10:07:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:852905b0-1362-40b1-8be5-a94dc40a892c</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Oh then I&amp;#39;m sorry that I&amp;#39;ve promised quick fix, it looks like some deeper bug completely unrelated to the way how you store/handle bytes in this part of your code. Are you sure that if you perform single connection and single transfer that the issue persists and it&amp;#39;s exactly at the 430th character regardless of buffer allocation method (static or dynamic)? This would be very very strange.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107408?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2017 09:46:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e80a9fa1-6b52-4be2-aab1-fa4cb49f62ce</guid><dc:creator>jj</dc:creator><description>&lt;p&gt;Thank you for the help. I tried what you suggested and is still encountering the same error.
I made another &lt;code&gt;strall&lt;/code&gt; buffer as I intend to manipulate the data received from BLE, and I am afraid there may be new data coming in when I am dealing with the original packet (resulting in strall to be the new data instead of the original one). As for the condition 123, the sending party put that as the indication of the end of the packet, hence in Nordic I am checking for it to know whether it receives the whole data. I changed size_t to uint32_t as well.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107410?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2017 07:15:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7b7dda7c-1f4a-4783-a7a8-756a57aa4b41</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Yes, I mean &lt;code&gt;static uint8_t buf[1000]&lt;/code&gt; at the beginning of your &lt;code&gt;main.c&lt;/code&gt; file instead of &lt;code&gt;uint8_t *buf = NULL;&lt;/code&gt;. You can set it by &lt;code&gt;memset&lt;/code&gt; once after the boot. Also your &lt;code&gt;strall&lt;/code&gt; buffer would need similar treatment, but to be honest I don&amp;#39;t know why you just don&amp;#39;t cast and use reference to &lt;code&gt;buf&lt;/code&gt; instead of making another large buffer. Finally I don&amp;#39;t see how you get the data to the buffer and why there is this magic condition with &lt;code&gt;123&lt;/code&gt; but I trust you know what to do there. Oh and one more: why you use &lt;code&gt;size_t&lt;/code&gt; and not some reasonable integer like &lt;code&gt;uint32_t&lt;/code&gt; for indexes and lengths? Maybe cosmetics, maybe not (depending on how &lt;code&gt;size_t&lt;/code&gt; gets recognized during linking after pre-processing all the macros and defines...)&lt;/p&gt;
&lt;p&gt;Maybe I will sound snobbish now but ARM Cortex-M isn&amp;#39;t windows machine with x64 core and unlimited resources, coding it like C++ on Win isn&amp;#39;t the best idea.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107409?ContentTypeID=1</link><pubDate>Thu, 09 Nov 2017 01:50:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ccead6f6-fed0-4bf0-afa6-94d6b656d91d</guid><dc:creator>jj</dc:creator><description>&lt;p&gt;May i know what you mean by global static 1kb buffer? I tried changing declaration to &amp;#39;uint8_t buf[1000]&amp;#39; but it is still not working even after I removed all malloc/realloc.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107418?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 14:36:54 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bd98b78d-7348-4030-8bf1-932864c39325</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Yes, that would be long read/writes then. But you would have to write them in parts too and in addition, you would have an addional parameter (the position in the characteristic) that would reduce the usable length to 18.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107417?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 14:29:01 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5355fe1c-006b-40c6-9217-187c5585866e</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;And to complete: ATT_MTU is maximum for Notifications and Indications but as far as I understand GATT Value can be longer (up to 512B) and independent on ATT_MTU size. You should be then able to use Read and/or Write methods to work with them in parts.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107416?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 14:24:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:bfbb6b34-b013-4739-83bd-03b2699a1f3a</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;Are you sure, that, whatever you use on the GATT client side, does not swallow writes? Have you used a sniffer?&lt;/p&gt;
&lt;p&gt;BTW: 20 is just the minimum (MTU-3). Right after a connection is established, client and server negotiate a value that might be larger.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107405?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 14:19:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7dc1a61e-8903-47b4-a821-4ece17c417b4</guid><dc:creator>Torsten Robitzki</dc:creator><description>&lt;p&gt;At least add a check for the result of &lt;code&gt;realloc()&lt;/code&gt; and &lt;code&gt;malloc()&lt;/code&gt; to be sure that this is not a heap fragmentation problem.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Unable to receive full data over BLE</title><link>https://devzone.nordicsemi.com/thread/107406?ContentTypeID=1</link><pubDate>Wed, 08 Nov 2017 11:22:55 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:45c8da23-e7df-4872-b6e5-81b1b8dc2821</guid><dc:creator>endnode</dc:creator><description>&lt;p&gt;Stop using malloc/realloc and similar crap and just create global static 1kB buffer. Your problem will be most probably (magically) solved;)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>