<?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 store the received data from ble nus into flash memory</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/55970/how-to-store-the-received-data-from-ble-nus-into-flash-memory</link><description>Hi... I have merged the ble_app_uart and fstorge example . I am storing the received data in a variable and passing in flash using nrf_fstorage_write command . I am getting nrf_breakpoint while I am sending the data from ble_app. Why ? What is the issue</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Wed, 17 Feb 2021 09:35:43 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/55970/how-to-store-the-received-data-from-ble-nus-into-flash-memory" /><item><title>RE: How to store the received data from ble nus into flash memory</title><link>https://devzone.nordicsemi.com/thread/294775?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2021 09:35:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:44e87974-a85a-4de8-b8b6-5c9990bf4a2c</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Could you open a new ticket and ask the question there?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to store the received data from ble nus into flash memory</title><link>https://devzone.nordicsemi.com/thread/294743?ContentTypeID=1</link><pubDate>Wed, 17 Feb 2021 05:06:28 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37e46651-9dd4-4191-b075-05412a2f7d39</guid><dc:creator>Jaydev Borkar</dc:creator><description>&lt;p&gt;Hi, I am also facing the same issue. The data is being received in p_data, but I am unable to write the received data to flash memory. I have tried using fds and fstorage. PFA the main.c file below. This is a snippet of the ble_data_handler and int_main().&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;pre class="ui-code" data-mode="c_cpp"&gt;char data[100];
uint32_t address=0x60000;
static void nus_data_handler(ble_nus_evt_t * p_evt)
{
    //ret_code_t err_code;
    app_uart_flush();
    if (p_evt-&amp;gt;type == BLE_NUS_EVT_RX_DATA &amp;amp;&amp;amp; p_evt-&amp;gt;params.rx_data.length&amp;gt;0)
    {
        uint32_t err_code;

        NRF_LOG_DEBUG(&amp;quot;Received data from BLE NUS. Writing data on UART.&amp;quot;);
        //NRF_LOG_HEXDUMP_DEBUG(p_evt-&amp;gt;params.rx_data.p_data, p_evt-&amp;gt;params.rx_data.length);
        for (uint32_t i = 0; i &amp;lt; p_evt-&amp;gt;params.rx_data.length; i++)
        {
            do
            {
                data[i]=p_evt-&amp;gt;params.rx_data.p_data[i];
                err_code = nrf_fstorage_write(&amp;amp;fstorage, address, p_evt-&amp;gt;params.rx_data.p_data[i], p_evt-&amp;gt;params.rx_data.length, NULL);
                //APP_ERROR_CHECK(err_code);
                address++;
                //err_code = app_uart_put(p_evt-&amp;gt;params.rx_data.p_data[i]);
                //if ((err_code != NRF_SUCCESS) &amp;amp;&amp;amp; (err_code != NRF_ERROR_BUSY))
                //{
                //    NRF_LOG_ERROR(&amp;quot;Failed receiving NUS message. Error 0x%x. &amp;quot;, err_code);
                //    APP_ERROR_CHECK(err_code);
                //}
            } while (err_code == NRF_ERROR_BUSY);
        }
        //if (p_evt-&amp;gt;params.rx_data.p_data[p_evt-&amp;gt;params.rx_data.length - 1] == &amp;#39;\r&amp;#39;)
        //{
        //    while (app_uart_put(&amp;#39;\n&amp;#39;) == NRF_ERROR_BUSY);
        //}
    }
    printf(&amp;quot;The length of data is: %d\n\r&amp;quot;,p_evt-&amp;gt;params.rx_data.length);
    ble_data_receive=true;
    printf(&amp;quot;BLE Data received and bool changed to true\n\r&amp;quot;);
}


int main(void)
{
////////////////////////////// F STORAGE CODE//////////////////////////

    ret_code_t err_code;
    nrf_fstorage_api_t * p_fs_api;
    p_fs_api = &amp;amp;nrf_fstorage_sd;
    err_code = nrf_fstorage_init(&amp;amp;fstorage, p_fs_api, NULL);
    APP_ERROR_CHECK(err_code);
 
//////////////////////////////// BLE UART CODE/////////////////////////    
    bool erase_bonds;
    // Initialize.
    uart_init();
    log_init();
    //cli_init();
    timer_init();
    power_management_init();
    ble_stack_init();
    gap_params_init();
    gatt_init();
    services_init();
    advertising_init();                         
    conn_params_init();
    advertising_start();
    //cli_start();
    // Enter main loop.
    for (;;)
    {
        idle_state_handle();
        if(ble_data_receive==true){
            const char sms[100]={&amp;quot;Hello we are speaking from sunlux technovations!&amp;quot;};
            printf(&amp;quot;Commencing write operation\n\r&amp;quot;);
            //err_code = nrf_fstorage_write(&amp;amp;fstorage, 0x60000, &amp;amp;data, 115, NULL);
            //APP_ERROR_CHECK(err_code);
            if(err_code==NRF_SUCCESS){
              printf(&amp;quot;Write operation done!\n\r&amp;quot;);
            }
            printf(&amp;quot;Printing data here\n\r&amp;quot;);
            printf(&amp;amp;data);
            //printf(&amp;quot;Printing ends here\n\r&amp;quot;);
            printf(&amp;quot;The data in String is: %s\n\r&amp;quot;,data);
            printf(&amp;quot;The data pointer value is: %d\n\r&amp;quot;,data);
            ble_data_receive=false;
            printf(&amp;quot;BLE Data received and bool changed to false\n\r&amp;quot;);
            //char a[100];uint32_t len=100;
            //printf(&amp;quot;Reading flash\n\r&amp;quot;);
            //ret_code_t rc;
            //rc=nrf_fstorage_read(&amp;amp;fstorage,0x200040D1,a,len);
            ////APP_ERROR_CHECK(rc);
            //printf(&amp;quot;The data is: %s\n\r&amp;quot;,a);
        }
        //cli_process();
    }
}
&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to store the received data from ble nus into flash memory</title><link>https://devzone.nordicsemi.com/thread/227900?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2020 13:24:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e68aab78-0b91-4356-9805-49d31dd0f0a2</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Could you upload your code (main.c) to this ticket? Then I can take a look at it and figure out what might cause the unwanted behavior. Click on Insert→Insert image/video/file&lt;span&gt;→From→File Upload, then find main.c and&amp;nbsp;click Ok.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to store the received data from ble nus into flash memory</title><link>https://devzone.nordicsemi.com/thread/227896?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2020 13:07:39 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c3da0341-877f-4f83-8676-ec7c4bf521e1</guid><dc:creator>ps_anu</dc:creator><description>&lt;p&gt;yes now i am done, can please tell me how to read ? and print the read message&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to store the received data from ble nus into flash memory</title><link>https://devzone.nordicsemi.com/thread/227893?ContentTypeID=1</link><pubDate>Tue, 07 Jan 2020 13:06:20 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:f06e12d7-90b4-43ca-9509-c6da0e4206d2</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Could you upload main.c?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to store the received data from ble nus into flash memory</title><link>https://devzone.nordicsemi.com/thread/227638?ContentTypeID=1</link><pubDate>Mon, 06 Jan 2020 11:01:18 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d1b8a5d9-03c0-466d-90e5-34c121080d5d</guid><dc:creator>ps_anu</dc:creator><description>&lt;p&gt;&amp;nbsp;Now , BLE connection is stable ,but i am not receive any data in termite . BLE APP to termite is not working , data i am not receiving . but termite to BLE APP i am getting the data ..what will be issue ?please help me&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to store the received data from ble nus into flash memory</title><link>https://devzone.nordicsemi.com/thread/227051?ContentTypeID=1</link><pubDate>Mon, 30 Dec 2019 10:30:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a0d4dca4-c4b0-4628-a06f-6cd9ebcfb12d</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;Could you try to &lt;a href="https://www.youtube.com/watch?v=uP8RYgYGRvI&amp;amp;t=24s"&gt;debug your project&lt;/a&gt; and see what function caused the error and what the error code is?&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: How to store the received data from ble nus into flash memory</title><link>https://devzone.nordicsemi.com/thread/227041?ContentTypeID=1</link><pubDate>Mon, 30 Dec 2019 09:43:08 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ea146acb-68f9-4824-a96d-250fc8f21665</guid><dc:creator>Simon</dc:creator><description>&lt;p&gt;A huge portion of the support team is currently on Christmas vacation and you may experience delayed answers. Most of the staff will be back 6 of January 2020 and you can&amp;nbsp;be sure to get an answer shortly after that.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;/p&gt;
&lt;p&gt;Simon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>