<?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>Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/32581/questions-regarding-ble-throughput</link><description>Hi. I&amp;#39;ve seen many questions here regarding BLE throughput, I&amp;#39;ve been trying to get something better than the 200 B/s I&amp;#39;m getting. 
 I am using a nrf52832 as a GATT server. 
 So, I now that if I have write commands instead of write requests, it should</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Mon, 09 Apr 2018 16:43:41 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/32581/questions-regarding-ble-throughput" /><item><title>RE: Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/thread/127496?ContentTypeID=1</link><pubDate>Mon, 09 Apr 2018 16:43:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:41bfb0de-0b90-47de-89fd-c7f99c5983aa</guid><dc:creator>alasknnj</dc:creator><description>&lt;p&gt;The problem turned out to be something unrelated to BLE settings. I was wrongly checking the size of the BLE packets and&amp;nbsp;writing the data on an array that was smaller than the actual size, which caused unpredictable problems and leaded to a crash.&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;I have not yet tested the data rate, but it is much higher now.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/thread/127079?ContentTypeID=1</link><pubDate>Thu, 05 Apr 2018 14:14:24 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:50bd9890-25d6-47d0-b680-4d38073f4584</guid><dc:creator>alasknnj</dc:creator><description>&lt;p&gt;MIN_CONN_INTERVAL is set to 50 ms, MAX_CONN_INTERVAL is set to 100 ms,&lt;/p&gt;
&lt;p&gt;additionally, SLAVE_LATENCY is set to 0 and CONN_SUP_TIMEOUT is 4 s.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/thread/127076?ContentTypeID=1</link><pubDate>Thu, 05 Apr 2018 14:02:57 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:5d371401-dfa8-48dd-af81-f39290ba3b00</guid><dc:creator>Sigurd</dc:creator><description>[quote userid="68264" url="~/f/nordic-q-a/32581/questions-regarding-ble-throughput/126724"]the value for MTU is set at 247 successfully, which should leave 244 bytes of user data right?[/quote]
&lt;p&gt;Correct.&lt;/p&gt;
&lt;p&gt;What connection interval are you using here? You should try to lower the connection interval in order to increase the&amp;nbsp;&lt;span&gt;throughput.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/thread/126724?ContentTypeID=1</link><pubDate>Wed, 04 Apr 2018 00:21:07 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:e8fb86b6-868d-4679-9c56-fb3ef92e7e2a</guid><dc:creator>alasknnj</dc:creator><description>&lt;p&gt;I see. I have tried those settings, still not going.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;My phone application sends a MTU request and I verified on the nordic aide that the exchange does not return an error, the value for MTU is set at 247 successfully, which should leave 244 bytes of user data right?&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Could you think of any other possible reason?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I may be able to give more details soon, we are currently focusing on other issues, but we really want to get a higher throughput&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/thread/126715?ContentTypeID=1</link><pubDate>Tue, 03 Apr 2018 19:52:32 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:dda4b499-5bf7-4399-a174-6c7eb82967b6</guid><dc:creator>Sigurd</dc:creator><description>[quote userid="68264" url="~/f/nordic-q-a/32581/questions-regarding-ble-throughput/126711"]What is the difference between ble_cfg_t.conn_cfg.params.gap_conn_cfg.event_length and the define&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH. I had the config param set to 320, but the define at 20, so I should set the define to 320 also&lt;/span&gt;[/quote]
&lt;p&gt;The define(NRF_SDH_BLE_GAP_EVENT_LENGTH) is just generally what &lt;em&gt;ble_cfg_t.conn_cfg.params.gap_conn_cfg.event_length&lt;/em&gt; is set to in nrf_sdh_ble_default_cfg_set().&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ble_cfg.conn_cfg.params.gap_conn_cfg.event_length = NRF_SDH_BLE_GAP_EVENT_LENGTH;&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&lt;br /&gt;&lt;br /&gt;&lt;/p&gt;
[quote userid="68264" url="~/f/nordic-q-a/32581/questions-regarding-ble-throughput/126711"]I am calling&amp;nbsp;sd_ble_gap_data_length_update when I receive a&amp;nbsp;BLE_GAP_EVT_CONNECTED, is that appropriate?[/quote]
&lt;p&gt;This is something the GATT module will do for you. On&amp;nbsp;BLE_GAP_EVT_CONNECTED, the gatt module will start&amp;nbsp;ATT MTU exchange and&amp;nbsp;data length update request if necessary(based on the NRF_SDH_BLE_GATT_MAX_MTU_SIZE value)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/thread/126711?ContentTypeID=1</link><pubDate>Tue, 03 Apr 2018 19:35:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:60115706-f756-46cd-8b46-afa4523d5442</guid><dc:creator>alasknnj</dc:creator><description>&lt;p&gt;I&amp;#39;m not able to test it now, but I am quite sure I already had those parameters. What is the difference between ble_cfg_t.conn_cfg.params.gap_conn_cfg.event_length and the define&amp;nbsp;&lt;span&gt;NRF_SDH_BLE_GAP_EVENT_LENGTH. I had the config param set to 320, but the define at 20, so I should set the define to 320 also?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;I am calling&amp;nbsp;sd_ble_gap_data_length_update when I receive a&amp;nbsp;BLE_GAP_EVT_CONNECTED, is that appropriate?&lt;/p&gt;
&lt;p&gt;As soon as I am able to test, I will confirm if I had those parameters. I will try to find some more useful things to help.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/thread/126710?ContentTypeID=1</link><pubDate>Tue, 03 Apr 2018 19:14:26 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:ae4f2141-ae8f-4120-9f78-05b20a042aef</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;The &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.sdk5.v14.2.0/lib_ble_gatt.html?cp=4_0_1_3_2_10"&gt;gatt module in the SDK&lt;/a&gt; handles the ATT MTU and DLE request and updates for you.&lt;/p&gt;
&lt;p&gt;Make sure that you have&amp;nbsp;&lt;em&gt;gatt_init();&lt;/em&gt;&amp;nbsp;in your main() function. gatt_init() should call the function&amp;nbsp;&lt;em&gt;nrf_ble_gatt_init()&lt;/em&gt;. Make sure that you set&amp;nbsp;&lt;em&gt;NRF_SDH_BLE_GATT_MAX_MTU_SIZE&lt;/em&gt;&amp;nbsp;to 247 in sdk_config.h, the DLE will be adjust automatically by the gatt module based on the value of NRF_SDH_BLE_GATT_MAX_MTU_SIZE.&lt;/p&gt;
&lt;p&gt;For maximum throughput you should also make sure that NRF_SDH_BLE_GAP_EVENT_LENGTH in sdk_config.h is set high enough (try to set it to 320).&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/thread/126707?ContentTypeID=1</link><pubDate>Tue, 03 Apr 2018 18:17:11 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1f6b7d54-be07-4f72-95bf-d254272d9101</guid><dc:creator>alasknnj</dc:creator><description>&lt;p&gt;How do I enable DLE? I haven&amp;#39;t found how to do that yet.&lt;/p&gt;
&lt;p&gt;I am using an Android 7.0 phone. If I change the size to something bigger than 52 bytes, the application crashes (nrf52832) whereas the Android seems to be OK.&lt;/p&gt;
&lt;p&gt;I am using SDK 14.2 and softdevice S132 v5. I am aware there is a newer SDK and softdevice, but I haven&amp;#39;t tried them yet.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Questions regarding BLE throughput</title><link>https://devzone.nordicsemi.com/thread/126703?ContentTypeID=1</link><pubDate>Tue, 03 Apr 2018 18:03:41 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b80122ef-5a77-479d-97a9-1a51948d4c9d</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="alasknnj"] Does write commands translate to BLE_GATTS_EVT_WRITE events and write requests to BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST event with type BLE_GATTS_AUTHORIZE_TYPE_WRITE? It&amp;#39;s not really clear. [/quote]
&lt;p&gt;I recommend taking a look at the different &lt;a href="https://infocenter.nordicsemi.com/topic/com.nordic.infocenter.s132.api.v5.0.0/group___b_l_e___g_a_t_t_s___m_s_c.html?cp=2_3_1_1_1_2_4_3"&gt;Message Sequence Charts&lt;/a&gt; for write commands and write requests.&lt;/p&gt;
&lt;p&gt;For write commands you will get an event &lt;em&gt;BLE_GATTS_EVT_WRITE with opcode&amp;nbsp;&lt;span&gt;BLE_GATTS_OP_WRITE_CMD.&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;For write requests the type of event you get will depend on if authorization is used or not. For &lt;em&gt;Write Request with Authorization&lt;/em&gt;, you will get &lt;em&gt;BLE_GATTS_EVT_RW_AUTHORIZE_REQUEST&lt;/em&gt; with type BLE_GATTS_AUTHORIZE_TYPE_WRITE.&lt;/p&gt;
&lt;p&gt;For Write Request without Authorization, you will get &lt;em&gt;BLE_GATTS_EVT_WRITE with opcode&amp;nbsp;&lt;span&gt;BLE_GATTS_OP_WRITE_REQ&lt;/span&gt;&lt;/em&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="alasknnj"] I have observed that inse the write request struct there is an OPCODE, could an event be triggered with opcode ==&amp;nbsp;BLE_GATTS_OP_WRITE_CMD? If so, wouldn&amp;#39;t I still need to send a reply? [/quote]
&lt;p&gt;If you get a BLE_GATTS_EVT_WRITE with opcode BLE_GATTS_OP_WRITE_CMD, then this is a write command. You don&amp;rsquo;t need to send a response.&lt;/p&gt;
[quote user="alasknnj"] Another way to improve the data rate is through a higher MTU, I have managed to send commands from the client side and set it to a higher value (243 ATT MTU size), so that leaves 240 bytes of application data right? But I still can&amp;#39;t send more than 52 application data bytes per packet, otherwise the MCU gets stuck somewhere before reaching the evt handler. So, my other question is:&lt;p&gt;&lt;/p&gt;&lt;p&gt;* How do I make use of the higher MTU data size I managed to set? Do I need to enable DLE, is that what makes it possible to use more than the 23 byte default size?&lt;/p&gt;[/quote]
&lt;p&gt;For maximum throughput, you can set the ATT MTU to 247, removing the 3 byte header, you have 244 byte payload per ATT MTU. Make sure that you increase the maximum attribute value length for your&amp;nbsp;characteristic.&amp;nbsp;You should also debug to find the reason why the code gets stuck.See&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/10729/my-device-is-freezing-and-restarting"&gt;this post&lt;/a&gt;.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Snippet:&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="text"&gt;ble_gatts_attr_t attr_char_value;
memset(&amp;amp;attr_char_value, 0, sizeof(attr_char_value));

attr_char_value.max_len = MY_MAX_VALUE; //(244) E.g. NRF_SDH_BLE_GATT_MAX_MTU_SIZE - OPCODE_LENGTH - HANDLE_LENGTH&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;With DLE you can set the on-air packet size up to 255 bytes, removing the L2CAP and LL header, we are left with 247 bytes. If DLE is not used, the ATT packet will be fragmented into several on-air packets. So for maximum throughput you should also enable DLE.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="alasknnj"] Is long write the same thing as reliable write? [/quote]
&lt;p&gt;They are very similar, but with one additional check when using reliable write. With reliable write each value that is prepared, the &amp;ldquo;Prepare Write Response&amp;rdquo; is compared with the request to ensure that the handle and the value in the response is the same as in the request.&lt;/p&gt;
&lt;p&gt;Note that long/reliable write is often very slow, because the client need to wait for the &amp;ldquo;Prepare Write Response&amp;rdquo; packet from the server before sending the next &amp;ldquo;Prepare Write Request&amp;rdquo;. Write commands and notifications are much faster, and don&amp;rsquo;t require a response.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
[quote user="alasknnj"] I need to transfer rather large packets to the GATT server, but I have been only able to do so by breaking it apart in chunks of 52 usable bytes per characteristic write (on Android). [/quote]
&lt;ul&gt;
&lt;li&gt;What phone are you using ? What happens if you increase it to more than 52?&lt;/li&gt;
&lt;li&gt;What SDK and SoftDevice version are you using?&lt;/li&gt;
&lt;/ul&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>