<?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>Reading and sending a CSV file</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/59342/reading-and-sending-a-csv-file</link><description>Hi, 
 I have CSV file stored on an SD card (which I create via the nordic board). I want to send this via a GATT connection. 
 I have gotten a service with a notifiable characteristic value that increments once per second using a notification timeout</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 24 Mar 2020 08:23:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/59342/reading-and-sending-a-csv-file" /><item><title>RE: Reading and sending a CSV file</title><link>https://devzone.nordicsemi.com/thread/241285?ContentTypeID=1</link><pubDate>Tue, 24 Mar 2020 08:23:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:40994fa5-d560-4a8f-b0cb-8120853c259e</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;I think you already have an open case with similar questions, so I suggest to continue there:&lt;br /&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/59222/sending-a-csv-file-over-ble-gatt-connection"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/59222/sending-a-csv-file-over-ble-gatt-connection&lt;/a&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading and sending a CSV file</title><link>https://devzone.nordicsemi.com/thread/241156?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 13:43:15 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:37754a26-310f-4ba0-ac01-47759e6617bb</guid><dc:creator>Thomas</dc:creator><description>&lt;p&gt;Thanks I&amp;#39;ve had a look at both of them and found the webpage quite useful. I have a CSV file that can be upto 1-2mBytes.&lt;/p&gt;
&lt;p&gt;I have a notification based example using a timeout handler can I not use this?&lt;/p&gt;
&lt;p&gt;I have a function that reads my CSV file and reads a line.&lt;/p&gt;
&lt;p&gt;I want to be able to send this single line using my ble_cus_custom_value_update function. But presently It only works for uint8_t.&lt;/p&gt;
&lt;p&gt;How do I change this to be much larger at least 51bytes as an individual line of data is 51 bytes. Thanks,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t ble_cus_custom_value_update(ble_cus_t * p_cus, uint8_t custom_value)
{
    NRF_LOG_INFO(&amp;quot;In ble_cus_custom_value_update. \r\n&amp;quot;); 
    if (p_cus == NULL)
    {
        return NRF_ERROR_NULL;
    }

    uint32_t err_code = NRF_SUCCESS;
    ble_gatts_value_t gatts_value;

    // Initialize value struct.
    memset(&amp;amp;gatts_value, 0, sizeof(gatts_value));

    gatts_value.len     = sizeof(uint8_t);
    gatts_value.offset  = 0;
    gatts_value.p_value = &amp;amp;custom_value;

    // Update database.
    err_code = sd_ble_gatts_value_set(p_cus-&amp;gt;conn_handle,
                                      p_cus-&amp;gt;custom_value_handles.value_handle,
                                      &amp;amp;gatts_value);
    if (err_code != NRF_SUCCESS)
    {
        return err_code;
    }

    // Send value if connected and notifying.
    if ((p_cus-&amp;gt;conn_handle != BLE_CONN_HANDLE_INVALID)) 
    {
        ble_gatts_hvx_params_t hvx_params;

        memset(&amp;amp;hvx_params, 0, sizeof(hvx_params));

        hvx_params.handle = p_cus-&amp;gt;custom_value_handles.value_handle;
        hvx_params.type   = BLE_GATT_HVX_NOTIFICATION;
        hvx_params.offset = gatts_value.offset;
        hvx_params.p_len  = &amp;amp;gatts_value.len;
        hvx_params.p_data = gatts_value.p_value;

        err_code = sd_ble_gatts_hvx(p_cus-&amp;gt;conn_handle, &amp;amp;hvx_params);
        NRF_LOG_INFO(&amp;quot;sd_ble_gatts_hvx result: %x. \r\n&amp;quot;, err_code); 
    }
    else
    {
        err_code = NRF_ERROR_INVALID_STATE;
        NRF_LOG_INFO(&amp;quot;sd_ble_gatts_hvx result: NRF_ERROR_INVALID_STATE. \r\n&amp;quot;); 
    }


    return err_code;
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Reading and sending a CSV file</title><link>https://devzone.nordicsemi.com/thread/241148?ContentTypeID=1</link><pubDate>Mon, 23 Mar 2020 13:26:22 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:719f2874-eaeb-4d0d-9e2a-31ff96f88150</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;In this case I suggest to check out the ble_app_uart example in the SDK, the example show central and peripheral example of generic (UART) data transfer between two peers. In your case you simply replace UART data with the data from the file system.&lt;/p&gt;
&lt;p&gt;In addition you should study the FatFs documentation and examples:&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://elm-chan.org/fsw/ff/00index_e.html"&gt;elm-chan.org/.../00index_e.html&lt;/a&gt;&amp;nbsp;and FatFs User Forum:&lt;span&gt;&amp;nbsp;&lt;/span&gt;&lt;a href="http://elm-chan.org/fsw/ff/bd/"&gt;http://elm-chan.org/fsw/ff/bd/&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;In short you call&amp;nbsp;f_read() to read data and to send data you call sd_ble_gatts_hvx(). You can call&amp;nbsp;f_read() multiple times until you have read the entire file.&lt;/p&gt;
&lt;p&gt;Best regards,&lt;br /&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>