<?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>Sending consecutive BLE notifications</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/42900/sending-consecutive-ble-notifications</link><description>Hi! I&amp;#39;ve got a nRF52 dev kit and I&amp;#39;m programming it with SDK 15 with Keil. When I send 3 consecutive BLE notifications (each notification is 4 bytes) to the Android app, the app reads the last notification 3 times. 
 I send the notifications in a loop</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 25 Jan 2019 15:12:29 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/42900/sending-consecutive-ble-notifications" /><item><title>RE: Sending consecutive BLE notifications</title><link>https://devzone.nordicsemi.com/thread/167995?ContentTypeID=1</link><pubDate>Fri, 25 Jan 2019 15:12:29 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b420c01f-9d0d-4ae4-846c-077bb7472492</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;It would be helpful if you could provide a &lt;a href="https://www.nordicsemi.com/-/media/DocLib/Other/User_Guides/nRFSnifferUGv22.pdf?la=en"&gt;sniffer trace&lt;/a&gt; of the connection, to know if the issue is on the nRF side or on the phone side.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending consecutive BLE notifications</title><link>https://devzone.nordicsemi.com/thread/167823?ContentTypeID=1</link><pubDate>Fri, 25 Jan 2019 08:30:43 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:869d57f2-5f17-4b89-8ebb-c95fa1941124</guid><dc:creator>IstvanS</dc:creator><description>&lt;p&gt;Fyi, I&amp;#39;ve decided to change the characteristic to send all data in one packet (6 data bytes + 2 bytes overhead). This should not be a problem then. However, it&amp;#39;s still interesting why it doesn&amp;#39;t work without the delay.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending consecutive BLE notifications</title><link>https://devzone.nordicsemi.com/thread/167807?ContentTypeID=1</link><pubDate>Fri, 25 Jan 2019 06:40:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1c092dd6-1b6e-414f-8d76-0b13fcf8e984</guid><dc:creator>IstvanS</dc:creator><description>&lt;p&gt;Without the delay, phone gets the last notification/data (i.e. data[0] = 3; data[1] = sensor_data[2]) 3 times.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending consecutive BLE notifications</title><link>https://devzone.nordicsemi.com/thread/167695?ContentTypeID=1</link><pubDate>Thu, 24 Jan 2019 15:10:19 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5eecc8ba-cf54-4db9-ba28-c0549e5a8ace</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Ok, that looks correct. Is it the first or the last data you are receiving if you do not put the delay?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending consecutive BLE notifications</title><link>https://devzone.nordicsemi.com/thread/167538?ContentTypeID=1</link><pubDate>Thu, 24 Jan 2019 07:23:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60b0203a-4dff-4d5b-a90c-e2700e584d13</guid><dc:creator>IstvanS</dc:creator><description>&lt;p&gt;This is ble_send():&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;uint32_t ble_send(uint16_t conn_handle, ble_abc_t * p_abc, uint8_t * data)
{
	ble_gatts_hvx_params_t params;
	uint16_t len = 4;

    memset(&amp;amp;params, 0, sizeof(params));
    params.type   = BLE_GATT_HVX_NOTIFICATION;
    params.handle = p_ams-&amp;gt;config_char_handles.value_handle;
    params.p_data = data;
    params.p_len  = &amp;amp;len;

    return sd_ble_gatts_hvx(conn_handle, &amp;amp;params);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;This is the function where notifications are sent:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;void sendDataControl(void)
{
	ret_code_t err_code;
	
	if(isDataReady)
	{
        uint16_t data[2];

        for (uint8_t i = 0; i &amp;lt; 3; i++)
        {
	        data[0] = i+1;
	        data[1] = u16_sensor_data[i]; // copy data from global array
			
	        err_code = ble_send(m_conn_handle, &amp;amp;m_abc, (uint8_t*)&amp;amp;data);
	        while (err_code != NRF_SUCCESS); // wait for NRF_SUCCESS
	        nrf_delay_ms(100); // with delay, phone app gets all data correctly
			                   // without delay, phone app gets the lastly sent data 3 times
	        if (err_code != NRF_SUCCESS &amp;amp;&amp;amp;
	        err_code != BLE_ERROR_INVALID_CONN_HANDLE &amp;amp;&amp;amp;
	        err_code != NRF_ERROR_INVALID_STATE &amp;amp;&amp;amp;
	        err_code != BLE_ERROR_GATTS_SYS_ATTR_MISSING)
	        {
		        APP_ERROR_CHECK(err_code);
	        }
        }
        
        isDataReady = false;
    }
}&lt;/pre&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Sending consecutive BLE notifications</title><link>https://devzone.nordicsemi.com/thread/167359?ContentTypeID=1</link><pubDate>Wed, 23 Jan 2019 12:08:42 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:3b81c073-b1ce-4c14-a9ba-cf597382f8bb</guid><dc:creator>J&amp;#248;rgen Holmefjord</dc:creator><description>&lt;p&gt;Can you post the code of&amp;nbsp;ble_send()? How is data updated between calls to ble_send() in the loop?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>