<?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>Ble Data Transfer Integrity</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42213/ble-data-transfer-integrity</link><description>I am trying to send data from a phone to the NRF51822. The data is being sent from the phone in 20 byte chunks to a write characteristic. When the event handler for receiving data is called, I use sd_ble_gatts_value_get() to get the data and copy it to</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 10 Jan 2019 22:51:42 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42213/ble-data-transfer-integrity" /><item><title>RE: Ble Data Transfer Integrity</title><link>https://devzone.nordicsemi.com/thread/165034?ContentTypeID=1</link><pubDate>Thu, 10 Jan 2019 22:51:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:83a67669-1681-45d0-ad5c-a7efaf07366f</guid><dc:creator>Nuri</dc:creator><description>&lt;p&gt;Using&amp;nbsp;&lt;span&gt;p_ble_evt-&amp;gt;evt.gatts_evt.params.write.len and&amp;nbsp;&lt;/span&gt;&lt;span&gt;p_ble_evt-&amp;gt;evt.gatts_evt.params.write.data instead of sd_ble_gatts_value_get() worked. Thanks for the help.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ble Data Transfer Integrity</title><link>https://devzone.nordicsemi.com/thread/165000?ContentTypeID=1</link><pubDate>Thu, 10 Jan 2019 16:11:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:57f18509-9522-4d6c-baf4-72adec0b96fa</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;It may be that rx_data is only valid in the&amp;nbsp;onCharWrite() context, so I assume then that&amp;nbsp;print_hex_buffer() is blocking here to make sure the entire buffer is output before you return from&amp;nbsp;&lt;span&gt;onCharWrite()?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Also,&amp;nbsp;I believe you don&amp;#39;t need to use&amp;nbsp;sd_ble_gatts_value_get(), I assume you are in the BLE event you should be able to use:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;p_ble_evt-&amp;gt;evt.gatts_evt.params.write.len;&lt;br /&gt;p_ble_evt-&amp;gt;evt.gatts_evt.params.write.data;&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Best regards,&lt;br /&gt;Kenneth&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ble Data Transfer Integrity</title><link>https://devzone.nordicsemi.com/thread/164804?ContentTypeID=1</link><pubDate>Thu, 10 Jan 2019 05:08:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:62c2f8fb-df3a-4ee9-a940-3d06881ddd96</guid><dc:creator>Nuri</dc:creator><description>&lt;p&gt;I have run the sniffer with my application, and I can tell that the correct data is being sent to the NRF51822. Here is the &lt;a href="https://drive.google.com/file/d/1bcJRbPpSB8oNhKsdutjvd3WMPsuLSBHF/view?usp=sharing" rel="noopener noreferrer" target="_blank"&gt;sniffer output&lt;/a&gt;&amp;nbsp;if you are curious. The following code is called when&amp;nbsp;BLE_GATTS_EVT_WRITE event occurs.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;#define MAX_PACKET_SIZE 20
static uint8_t data_buffer[MAX_PACKET_SIZE];
void onCharWrite(ble_evt_t * p_ble_evt)
{
    // Populate ble_gatts_value_t structure to hold received data and metadata.
    ble_gatts_value_t rx_data;
    rx_data.len = MAX_PACKET_SIZE;
    rx_data.offset = 0;
    rx_data.p_value = data_buffer;
    ble_gatts_evt_write_t * p_evt_write = &amp;amp;p_ble_evt-&amp;gt;evt.gatts_evt.params.write;
    uint32_t error = NRF_SUCCESS;
    const uint16_t WriteHandle = p_evt_write-&amp;gt;handle;

    if (WriteHandle == CharWriteHandles.value_handle)
    {
        // Get data
        memset(data_buffer, 0, MAX_PACKET_SIZE);
        error = sd_ble_gatts_value_get(zwConnection, CharWriteHandles.value_handle, &amp;amp;rx_data);
        APP_ERROR_CHECK(error);
        
        print_hex_buffer(&amp;amp;data_buffer[rx_data.offset], rx_data.len);
        
        //Copying to buffers and other processing
    }
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;Is there something wrong with the way this is being handled?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Ble Data Transfer Integrity</title><link>https://devzone.nordicsemi.com/thread/164506?ContentTypeID=1</link><pubDate>Tue, 08 Jan 2019 12:08:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:9fbcd85f-1e3b-4b21-b41b-de2dd9560a2f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;All data transferred over BLE is reliable, so I suspect you have some issues other place, for instance in the application handling in the central or peripheral. To check where the problem may be you might need to create a sniffer log and send to me when the problem occurs.&lt;/p&gt;
&lt;p&gt;&lt;a href="https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Sniffer"&gt;https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Sniffer&lt;/a&gt;&amp;nbsp;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>