<?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>Max data length over BLE</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/35927/max-data-length-over-ble</link><description>Hello, 
 
 I&amp;#39;m a little bit confused about max datalength that can be read/written in a characteristic. 
 
 See attached, a MTU of 64 bytes is negotiated thus 61 bytes available for the data itself in a packet. 
 In case I want to send data from an App</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Fri, 29 Jun 2018 10:59:17 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/35927/max-data-length-over-ble" /><item><title>RE: Max data length over BLE</title><link>https://devzone.nordicsemi.com/thread/138252?ContentTypeID=1</link><pubDate>Fri, 29 Jun 2018 10:59:17 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:510f5af0-8046-4a67-be9a-39acee45fe50</guid><dc:creator>H&amp;#229;kon Alseth</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In the &amp;quot;older scenario&amp;quot;, where the actual throughput was 20 bytes of user data, this scenario is valid:&lt;/p&gt;
&lt;p&gt;&lt;a href="https://devzone.nordicsemi.com/f/nordic-q-a/1105/how-do-i-calculate-throughput-for-a-ble-link"&gt;https://devzone.nordicsemi.com/f/nordic-q-a/1105/how-do-i-calculate-throughput-for-a-ble-link&lt;/a&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Since you mention larger MTU size, the nRF52xxx can have a MTU size of up to 247 bytes&amp;nbsp;(sdk_config.h::NRF_SDH_BLE_GATT_MAX_MTU_SIZE) vs. the &amp;quot;legacy&amp;quot; 23 bytes (note: 3 bytes overhead, 20 bytes user data).&lt;/p&gt;
&lt;p&gt;However, since the peripheral can do up to 247 bytes does not automatically mean that the central will also accept this MTU size. You might get 64 bytes (or 23 bytes) once the link between the peripheral and central is established. In order to satisfy the size as given by the central, you can store the agreed upon MTU size, which will be located in the callback for the GATT handler module (here taken from the ble_app_hrs example in SDK 15):&lt;/p&gt;
&lt;p&gt;&lt;pre class="ui-code" data-mode="c_cpp"&gt;/**@brief GATT module event handler.
 */
static void 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_ATT_MTU_UPDATED)
    {
        NRF_LOG_INFO(&amp;quot;GATT ATT MTU on connection 0x%x changed to %d.&amp;quot;,
                     p_evt-&amp;gt;conn_handle,
                     p_evt-&amp;gt;params.att_mtu_effective);
    }

    ble_hrs_on_gatt_evt(&amp;amp;m_hrs, p_evt);
}&lt;/pre&gt;&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;In addition to this, you have a parameter called &amp;quot;GAP event length&amp;quot; (sdk_config.h::NRF_SDH_BLE_GAP_EVENT_LENGTH), which gives you the maximum length of each connection interval (in 1.25 ms slots), which states how many packets per interval you can potentially send within one connection interval. This is the same principle as the MTU size, meaning that the central and peripheral has to agree upon a number (up to define NRF_SDH_BLE_GAP_EVENT_LENGTH).&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I&amp;#39;d recommend that you set the two above mentioned defines high (or use the default values in most examples in SDK 15) and try to continuously push packets through the link to see what speed you get with different phones.&lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Kind regards,&lt;/p&gt;
&lt;p&gt;Håkon&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>