<?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>MTU change does not change packet size</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/48593/mtu-change-does-not-change-packet-size</link><description>Setup: 
 periheral: RF52840, S140 softdevice (SDK 15.3) 
 central: for test/development: laptop with Linux and BLE adapter build in, and/or Raspberry Pi, using Python testing script, later phone and other nRF device 
 We are using the NUS peripheral example</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Tue, 13 Jul 2021 15:00:38 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/48593/mtu-change-does-not-change-packet-size" /><item><title>RE: MTU change does not change packet size</title><link>https://devzone.nordicsemi.com/thread/319870?ContentTypeID=1</link><pubDate>Tue, 13 Jul 2021 15:00:38 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:d60ff81d-4f00-4261-b203-4882070f3138</guid><dc:creator>samueltf</dc:creator><description>&lt;p&gt;I had a similar issue wiht nrf52805. This solution worked perfectly, thanks a lot.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MTU change does not change packet size</title><link>https://devzone.nordicsemi.com/thread/253593?ContentTypeID=1</link><pubDate>Fri, 05 Jun 2020 15:09:06 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:b2618fa9-66a2-44d0-b68c-e7367c8ef6d1</guid><dc:creator>Sigurd</dc:creator><description>[quote user="MMedved"]I&amp;#39;d really prefer not to modify the Nordic SDK if possible... is there another way to do this?[/quote]
&lt;p&gt;&amp;nbsp;If you are using the BLE GATT library, you would need to make a tiny&amp;nbsp;change to get the desired behavior.&lt;/p&gt;
[quote user="MMedved"]what the implications for other connections would be if the stack isnt initiating MTU transfer?[/quote]
&lt;p&gt;&amp;nbsp;You would be using the&amp;nbsp;default ATT MTU until either master or slave starts an ATT MTU exchange update. If you want to start the exchange later, you could call the&amp;nbsp;&lt;span&gt;sd_ble_gattc_exchange_mtu_request() function.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;This post here is quite old. If you have more questions about this, please create a new post:&amp;nbsp;&lt;a href="https://devzone.nordicsemi.com/support/add"&gt;https://devzone.nordicsemi.com/support/add&lt;/a&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MTU change does not change packet size</title><link>https://devzone.nordicsemi.com/thread/251923?ContentTypeID=1</link><pubDate>Wed, 27 May 2020 11:21:21 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:89ba33e6-3eec-4395-8765-bc8676f569a1</guid><dc:creator>Mike</dc:creator><description>&lt;p&gt;Sigurd - I&amp;#39;ve been messing around with this exact problem for a couple of days now.&amp;nbsp; I have a product with an NRF52840 built into it, and Im using an RPI 4.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;I think the problem has something to do with bluepy, and the weird way it directly includes code from the bluez stack, even though most of us have bluez already running as a service in our system.&amp;nbsp; I found that it isn&amp;#39;t my RPI4 that can&amp;#39;t handle the data length change, because if I manually activate my NUS service with bluetoothctl, it streams &amp;quot;big&amp;quot; packets just fine.&lt;/p&gt;
&lt;p&gt;However, when using bluepy, I get the same problem described above.&amp;nbsp; In fact, my data gets truncated at 20 bytes as described in a handful of posts elsewhere on the internet.&lt;/p&gt;
&lt;p&gt;When I modified my code as you described, however, it all seems to work, so your intuition seemed correct.&amp;nbsp; I&amp;#39;m not sure I really understand why though... in my code, I use the setMTU command to start an MTU negotiation from the Pi after connection.&lt;/p&gt;
&lt;p&gt;I&amp;#39;d really prefer not to modify the Nordic SDK if possible... is there another way to do this?&amp;nbsp; I&amp;#39;m guessing not.&amp;nbsp; I&amp;#39;m also curious what the implications for other connections would be if the stack isnt initiating MTU transfer?&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MTU change does not change packet size</title><link>https://devzone.nordicsemi.com/thread/193356?ContentTypeID=1</link><pubDate>Tue, 18 Jun 2019 09:22:25 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:97e00c39-b593-471f-9fe5-0375a627279a</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;What is the value of&amp;nbsp;m_ble_nus_max_data_len when you send the 67 bytes?&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Did&amp;nbsp;ble_nus_data_send() return&amp;nbsp;NRF_SUCCESS ?&lt;/p&gt;
&lt;p&gt;When the SD&amp;nbsp;starts the ATT MTU update&amp;nbsp;exchange, the peer/laptop reports that it does not support the request... but then after service&amp;nbsp;discovery, it starts the&amp;nbsp;&lt;span&gt;update&amp;nbsp;&lt;/span&gt;&lt;span&gt;exchange.&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Does the behavior&amp;nbsp;change if SD does not start the ATT MTU update exchange ? In order to test this, try&amp;nbsp;modifying&amp;nbsp;on_connected_evt() function in nrf_ble_gatt.c to this:&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;&lt;pre class="ui-code" data-mode="text"&gt;static void on_connected_evt(nrf_ble_gatt_t * p_gatt, ble_evt_t const * p_ble_evt)
{
    ret_code_t            err_code;
    uint16_t              conn_handle = p_ble_evt-&amp;gt;evt.common_evt.conn_handle;
    nrf_ble_gatt_link_t * p_link      = &amp;amp;p_gatt-&amp;gt;links[conn_handle];

    // Update the link desired settings to reflect the current global settings.
#if !defined (S112) &amp;amp;&amp;amp; !defined(S312)
    p_link-&amp;gt;data_length_desired = p_gatt-&amp;gt;data_length;
#endif // !defined (S112) &amp;amp;&amp;amp; !defined(S312)

    switch (p_ble_evt-&amp;gt;evt.gap_evt.params.connected.role)
    {
        case BLE_GAP_ROLE_PERIPH:
            p_link-&amp;gt;att_mtu_desired = p_gatt-&amp;gt;att_mtu_desired_periph;
            break;

#if !defined (S112) &amp;amp;&amp;amp; !defined(S312)
        case BLE_GAP_ROLE_CENTRAL:
            p_link-&amp;gt;att_mtu_desired = p_gatt-&amp;gt;att_mtu_desired_central;
            break;
#endif // !defined (S112) &amp;amp;&amp;amp; !defined(S312)

        default:
            // Ignore.
            break;
    }

    // Begin an ATT MTU exchange if necessary.
    bool start_att_mtu_exchange_on_connect = false; 
    if (p_link-&amp;gt;att_mtu_desired &amp;gt; p_link-&amp;gt;att_mtu_effective &amp;amp;&amp;amp; start_att_mtu_exchange_on_connect)
    {
        NRF_LOG_DEBUG(&amp;quot;Requesting to update ATT MTU to %u bytes on connection 0x%x.&amp;quot;,
                      p_link-&amp;gt;att_mtu_desired, conn_handle);

        err_code = sd_ble_gattc_exchange_mtu_request(conn_handle, p_link-&amp;gt;att_mtu_desired);

        if (err_code == NRF_SUCCESS)
        {
            p_link-&amp;gt;att_mtu_exchange_requested = true;
        }
        else if (err_code == NRF_ERROR_BUSY)
        {
            p_link-&amp;gt;att_mtu_exchange_pending = true;
            NRF_LOG_DEBUG(&amp;quot;sd_ble_gattc_exchange_mtu_request()&amp;quot;
                          &amp;quot; on connection 0x%x returned busy, will retry.&amp;quot;, conn_handle);
        }
        else
        {
            NRF_LOG_ERROR(&amp;quot;sd_ble_gattc_exchange_mtu_request() returned %s.&amp;quot;,
                          nrf_strerror_get(err_code));
        }
    }

#if !defined (S112) &amp;amp;&amp;amp; !defined(S312)
    // Send a data length update request if necessary.
    if (p_link-&amp;gt;data_length_desired &amp;gt; p_link-&amp;gt;data_length_effective)
    {
        (void) data_length_update(conn_handle, p_link-&amp;gt;data_length_desired);
    }
#endif // !defined (S112) &amp;amp;&amp;amp; !defined(S312)
}&lt;/pre&gt;&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MTU change does not change packet size</title><link>https://devzone.nordicsemi.com/thread/193109?ContentTypeID=1</link><pubDate>Mon, 17 Jun 2019 09:20:31 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:a566f711-fc4a-4b14-96f1-e54007189d76</guid><dc:creator>HGrobben</dc:creator><description>&lt;p&gt;Update: I&amp;#39;ve tried with my phone, sending a bogus command and I do get more that 20 Bytes. Same setup, running with my laptop: only 20 Bytes. So it seems to be an issue with the bluetooth stack in the laptop.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MTU change does not change packet size</title><link>https://devzone.nordicsemi.com/thread/192944?ContentTypeID=1</link><pubDate>Fri, 14 Jun 2019 13:28:47 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:1aacd7c0-71d0-43e8-8f45-24418ebc7d1c</guid><dc:creator>HGrobben</dc:creator><description>&lt;p&gt;No, at the moment I only have a custom board with a Nordic chip.&lt;/p&gt;
&lt;p&gt;Here is the log: &lt;a href="http://gofile.me/2ot6Z/aIxW0xe2K"&gt;btmon log&lt;/a&gt; (available for few days only)&lt;/p&gt;
&lt;p&gt;2 transfers: 1st is OK (log entry 59: less then 20 bytes), second transfer is not OK (line 62, should be 67 Bytes)&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: MTU change does not change packet size</title><link>https://devzone.nordicsemi.com/thread/192937?ContentTypeID=1</link><pubDate>Fri, 14 Jun 2019 13:16:44 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:190846e6-1a72-4727-8e3c-b6177416aca6</guid><dc:creator>Sigurd</dc:creator><description>&lt;p&gt;Hi,&lt;/p&gt;
&lt;p&gt;Could you upload the&amp;nbsp;&lt;span&gt;btmon log ?&lt;/span&gt;&lt;/p&gt;
&lt;p&gt;&lt;span&gt;Do you have a spare nRF5x-DK ? If yes, then a &lt;a href="https://www.nordicsemi.com/Software-and-Tools/Development-Tools/nRF-Sniffer"&gt;nRF sniffer v2&lt;/a&gt; log would also be useful.&lt;/span&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>