<?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 communication speed. How to setting?</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/72911/ble-communication-speed-how-to-setting</link><description>Hello. 
 
 I trying the test for real time transfer a data. 
 
 Period is 4 ms and 5000 point data. (Total 20 sec) 
 
 The GPIOTE event occurs every 4ms and the processed data is transmitted at that time. 
 
 But, Data loss occurs in nRF connect app when</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 18 Mar 2021 10:28:40 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/72911/ble-communication-speed-how-to-setting" /><item><title>RE: BLE communication speed. How to setting?</title><link>https://devzone.nordicsemi.com/thread/300633?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 10:28:40 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41fdf686-9500-49d3-adc0-c43d89dd037f</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;An on-air sniffer log would be helpful:&lt;br /&gt;&lt;a href="https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Sniffer-for-Bluetooth-LE"&gt;https://www.nordicsemi.com/Software-and-tools/Development-Tools/nRF-Sniffer-for-Bluetooth-LE&lt;br /&gt;&lt;/a&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/ug_sniffer_ble/UG/sniffer_ble/intro.html"&gt;https://infocenter.nordicsemi.com/topic/ug_sniffer_ble/UG/sniffer_ble/intro.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;Kenneth&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE communication speed. How to setting?</title><link>https://devzone.nordicsemi.com/thread/300557?ContentTypeID=1</link><pubDate>Thu, 18 Mar 2021 04:54:56 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7c52ce5e-dec7-4406-9585-e0b9787b4971</guid><dc:creator>Daeho</dc:creator><description>&lt;p&gt;Thank you for reply.&lt;/p&gt;
&lt;p&gt;I am currently using GPIOTE and BLE together.&lt;/p&gt;
&lt;p&gt;Data is transmitted to the smartphone via BLE every 4ms.&lt;/p&gt;
&lt;p&gt;However, data is lost in the middle.&lt;/p&gt;
&lt;p&gt;Do you have any idea why?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: BLE communication speed. How to setting?</title><link>https://devzone.nordicsemi.com/thread/300437?ContentTypeID=1</link><pubDate>Wed, 17 Mar 2021 13:50:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:4ad82e57-f69f-443c-92aa-9ac4cd1609dc</guid><dc:creator>Kenneth</dc:creator><description>&lt;p&gt;To be able to transfer data fast you need to update some parameters after connection is established:&lt;/p&gt;
&lt;p&gt;Typically the gatt_init() module will handle ATT MTU and DLE update for you, the gatt_init() will after an connection is established update the ATT MTU and DLE size that is used for communication (larger is more effective):&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/group___b_l_e___g_a_p___d_a_t_a___l_e_n_g_t_h___u_p_d_a_t_e___p_r_o_c_e_d_u_r_e___m_s_c.html"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/group___b_l_e___g_a_p___d_a_t_a___l_e_n_g_t_h___u_p_d_a_t_e___p_r_o_c_e_d_u_r_e___m_s_c.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;void nrf_ble_gatt_evt_handler(nrf_ble_gatt_t * p_gatt, nrf_ble_gatt_evt_t const * p_evt)
{
	if(p_evt-&amp;gt;evt_id == NRF_BLE_GATT_EVT_DATA_LENGTH_UPDATED)
	{
		// p_evt-&amp;gt;params.data_length is the max length on-air
	}	
	if(p_evt-&amp;gt;evt_id == NRF_BLE_GATT_EVT_ATT_MTU_UPDATED)
	{
		// p_evt-&amp;gt;params.att_mtu_effective is the max attribute mtu size		
	}	
	
	// Once both are updated, then you can start sending notifications that is longer than 20bytes effectively.
    // Though you should also make sure attr_char_value.max_len is set to support notifications that are
    // more than 20bytes when calling sd_ble_gatts_characteristic_add().
}

/**@brief Function for initializing the GATT module.
 */
static void gatt_init(void)
{
    ret_code_t err_code = nrf_ble_gatt_init(&amp;amp;m_gatt, nrf_ble_gatt_evt_handler);
    APP_ERROR_CHECK(err_code);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;After ATT MTU and DLE update you may send notifications that are for instance 240bytes instead of only 20bytes.&lt;/p&gt;
&lt;p&gt;The PHY can be updated by calling&amp;nbsp;sd_ble_gap_phy_update() after connection is established, this will result in an&amp;nbsp;BLE_GAP_EVT_PHY_UPDATE event on completion:&lt;br /&gt;&lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/group___b_l_e___g_a_p___e_v_t___p_h_y___m_s_c.html"&gt;https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v7.2.0/group___b_l_e___g_a_p___e_v_t___p_h_y___m_s_c.html&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;After PHY is updated you likely will be send more packets overall, since the time on air is lower.&lt;/p&gt;
&lt;p&gt;So, it is only after the phy, att mtu and dle have been updated that you can start effectively to transmit and receive high throughput data.&lt;/p&gt;
&lt;p&gt;The next step is to look at the connection intervals, most phones support for instance 30ms connection intervals, so you may want to set the preferred connection interval to 30ms, if you include&amp;nbsp;conn_params_init() then it will most likely handle this for you. If you specify a&amp;nbsp;cp_init.evt_handler when calling&amp;nbsp;&lt;span&gt;conn_params_init(), you may be notified in the application when the connection parameters are updated, similar&amp;nbsp;to nrf_ble_gatt_evt_handler() for ATT MTU and DLE update above.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Now you can call&amp;nbsp;sd_ble_gatts_hvx() as fast as possible,&amp;nbsp;but make sure that you handle the error codes in some way. For instance if you receive&amp;nbsp;sd_ble_gatts_hvx() return&amp;nbsp;NRF_ERROR_RESOURCES, then this means the internal buffer in the softdevice is full, and you need to wait until&amp;nbsp;BLE_GATTS_EVT_HVN_TX_COMPLETE before you should call&amp;nbsp;sd_ble_gatts_hvx() again until&amp;nbsp;NRF_ERROR_RESOURCES and so on.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Note: if your sensor generate data every 4ms, then don&amp;#39;t call&amp;nbsp;sd_ble_gatts_hvx() every 4ms, this will be very ineffective. You need to combine several sample data into one&amp;nbsp;sd_ble_gatts_hvx(), for instance you can combine 10 readings into one sd_ble_gatts_hvx(). Just make sure the total number of bytes for instance is -3 bytes less than reported in the&amp;nbsp;nrf_ble_gatt_evt_handler(). The -3 bytes are due to overhead in the packet.&amp;nbsp;&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;p&gt;&lt;span&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>