<?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>Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/37984/load-received-ble-data-into-an-array</link><description>Hello. I am using the nRF51 Development Kit which is working well. I am using the examples\ble_peripheral\ble_app_uart sample project as it seems to have the features that I am looking for, ie., receive BLE data from and external device. I do not need</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Sat, 08 Sep 2018 03:41:37 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/37984/load-received-ble-data-into-an-array" /><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/147870?ContentTypeID=1</link><pubDate>Sat, 08 Sep 2018 03:41:37 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cc52c93c-6de0-419c-9523-c3c110523b85</guid><dc:creator>brian fleming</dc:creator><description>&lt;p&gt;Hello, I was just doing some testing, and I have found that it is not necessary to include the&amp;nbsp;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;ble_gatt.h .&amp;nbsp; All that is required to save the BLE data into a user&amp;#39;s array is the memcpy() function.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;Cheers, Brian&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span style="background-color:transparent;color:#000000;float:none;font-family:Verdana,Arial,Helvetica,sans-serif;font-size:12px;font-style:normal;font-weight:400;letter-spacing:normal;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;div&gt;// #include &amp;lt;ble_gatt.h&amp;gt;&lt;/div&gt;
&lt;div&gt;uint8_t ble_data[BLE_NUS_MAX_DATA_LEN]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;;&lt;br /&gt;static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;memcpy( ble_data, p_data, length )&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;;&lt;/div&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/147446?ContentTypeID=1</link><pubDate>Wed, 05 Sep 2018 21:34:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:fd10182b-f419-4a95-91e8-c92081a1d030</guid><dc:creator>brian fleming</dc:creator><description>&lt;p&gt;Hello, just got my testing done, and your fix works!&lt;/p&gt;
&lt;p&gt;Since in my application, we will always be receiving a known length of BLE data I changed the code to the following.&lt;/p&gt;
&lt;p&gt;I strongly recommend that you add your solution to the SDK because judging by the number of views to my question, I can&amp;#39;t be the only person who would like to process the received BLE data internally instead of sending it out a serial port.&lt;/p&gt;
&lt;p&gt;Thank you for your expert assistance!&lt;/p&gt;
&lt;p&gt;Cheers, Brian&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;uint8_t ble_data[22]&amp;nbsp; &amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;;&lt;br /&gt;static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)&lt;br /&gt;{&lt;br /&gt;&amp;nbsp;&amp;nbsp; memcpy(ble_data, p_data, length)&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;;&amp;nbsp;&amp;nbsp;&amp;nbsp; &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (uint32_t i = 0; i &amp;lt; length; i++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (app_uart_put(p_data[i]) != NRF_SUCCESS);&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/146972?ContentTypeID=1</link><pubDate>Mon, 03 Sep 2018 12:30:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a718a290-0a24-4d95-92de-29227e2cb472</guid><dc:creator>brian fleming</dc:creator><description>&lt;p&gt;Hello,&amp;nbsp; I have to go now, but shouldn&amp;#39;t&amp;nbsp; the memcpy be inside the for structure like below?&amp;nbsp; I will test the code when I return.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; for (uint32_t i = 0; i &amp;lt; length; i++)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; {&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; while (app_uart_put(p_data[i]) != NRF_SUCCESS);&lt;br /&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp;&amp;nbsp; memcpy(ble_data, p_data, length)&amp;nbsp;&amp;nbsp;&amp;nbsp;;&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; }&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/146962?ContentTypeID=1</link><pubDate>Mon, 03 Sep 2018 12:04:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9f66b737-0998-4ea5-ae41-ca45bed2ccca</guid><dc:creator>brian fleming</dc:creator><description>&lt;p&gt;Thanks, it is compiling with no errors, but unfortunately I have to leave the office for a couple days, so I will not be able to test the code for a couple days.&amp;nbsp; Cheers.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/146889?ContentTypeID=1</link><pubDate>Mon, 03 Sep 2018 07:29:49 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e2ee4295-5ab2-4bb7-b316-02772af64783</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;#include &amp;lt;ble_gatt.h&amp;gt;
uint8_t ble_data[BLE_NUS_MAX_DATA_LEN];

static void nus_data_handler(ble_nus_t * p_nus, uint8_t * p_data, uint16_t length)
{
    memcpy(ble_data, p_data, length);
    
    for (uint32_t i = 0; i &amp;lt; length; i++)
    {
        while (app_uart_put(p_data[i]) != NRF_SUCCESS);
    }
    while (app_uart_put(&amp;#39;\r&amp;#39;) != NRF_SUCCESS);
    while (app_uart_put(&amp;#39;\n&amp;#39;) != NRF_SUCCESS);
}
/**@snippet [Handling the data received over BLE] */&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/146837?ContentTypeID=1</link><pubDate>Sat, 01 Sep 2018 00:31:51 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:2c89d2fb-eae5-4a45-9783-7b4b55f8fe9f</guid><dc:creator>brian fleming</dc:creator><description>&lt;p&gt;After doing a search for &amp;nbsp;&lt;span style="background-color:transparent;color:#11171a;float:none;font-family:&amp;#39;GT Eesti&amp;#39;,&amp;#39;Helvetica&amp;#39;,Arial,sans-serif;font-size:14px;font-style:normal;font-weight:400;letter-spacing:normal;line-height:21px;text-align:left;text-decoration:none;text-indent:0px;text-transform:none;white-space:normal;"&gt;BLE_GATT_ATT_MTU_DEFAULT&lt;/span&gt; I fount this link which had #include &amp;lt;ble_gatt.h&amp;gt; which was not in the example code, but still shows the same errors.&amp;nbsp; &lt;a href="https://infocenter.nordicsemi.com/index.jsp?topic=%2Fcom.nordic.infocenter.s132.api.v4.0.2%2Fstructble__gatt__conn__cfg__t.html"&gt;infocenter.nordicsemi.com/index.jsp&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/146580?ContentTypeID=1</link><pubDate>Thu, 30 Aug 2018 17:12:58 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:96a7b0df-607f-44a3-9f0d-c2aefc756fed</guid><dc:creator>brian fleming</dc:creator><description>&lt;p&gt;It has been many months since I did the installation, but I hope this is what you are looking for. &amp;nbsp;&lt;img alt=" " src="https://devzone.nordicsemi.com/resized-image/__size/320x240/__key/communityserver-discussions-components-files/4/nordic_5F00_sdk.JPG" /&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/146576?ContentTypeID=1</link><pubDate>Thu, 30 Aug 2018 16:34:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9bb61bf4-cbf1-465d-8c41-c6e1ef7d488e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;What SDK are you using?&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/146551?ContentTypeID=1</link><pubDate>Thu, 30 Aug 2018 14:48:00 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ee38656c-e749-43a3-bc15-e336a3259291</guid><dc:creator>brian fleming</dc:creator><description>&lt;p&gt;Thank you so much for your answer.&amp;nbsp; If I place the code in nus_data_handler I get the following errors at the end of this message.&amp;nbsp; Can you suggest an example program which has the complete working code which would load the array as you are suggesting?&amp;nbsp; Thanks so much for you assistance.&lt;/p&gt;
&lt;p&gt;*** Using Compiler &amp;#39;V5.06 update 5 (build 528)&amp;#39;, folder: &amp;#39;C:\Keil_v5\ARM\ARMCC\Bin&amp;#39;&lt;br /&gt;Build target &amp;#39;nrf51422_xxac&amp;#39;&lt;br /&gt;compiling main.c...&lt;br /&gt;..\..\..\main.c(151): error:&amp;nbsp; #20: identifier &amp;quot;BLE_GATT_ATT_MTU_DEFAULT&amp;quot; is undefined&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;uint8_t ble_data[BLE_GATT_ATT_MTU_DEFAULT - 3]&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;;&lt;br /&gt;..\..\..\main.c(152): error:&amp;nbsp; #20: identifier &amp;quot;p_evt&amp;quot; is undefined&lt;br /&gt;&amp;nbsp; &amp;nbsp;&amp;nbsp;memcpy(ble_data, p_evt-&amp;gt;params.rx_data.p_data, p_evt-&amp;gt;params.rx_data.length)&amp;nbsp;;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Load received BLE data into an array.</title><link>https://devzone.nordicsemi.com/thread/146515?ContentTypeID=1</link><pubDate>Thu, 30 Aug 2018 12:53:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97d8ff3e-7c96-4b4d-9481-1e75370a9f46</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Typically you use &lt;a href="http://www.cplusplus.com/reference/cstring/memcpy/"&gt;memcpy()&lt;/a&gt; for this,&amp;nbsp;something like:&lt;/p&gt;
&lt;p&gt;uint8_t ble_data[BLE_GATT_ATT_MTU_DEFAULT - 3];&lt;br /&gt; memcpy(ble_data, p_evt-&amp;gt;params.rx_data.p_data, p_evt-&amp;gt;params.rx_data.length);&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>