<?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>Android Ble library MTU change on peripheral</title><link>https://devzone.nordicsemi.com/f/nordic-q-a/97206/android-ble-library-mtu-change-on-peripheral</link><description>Hello, 
 
 I have some troubles understanding the design of the MTU exchange within the Android Nordic Library. 
 We are using a NRF52840 SDK 17 softdevice version 7.2.0 and a mobile application which integrated the Android Nordic Library version 2.6</description><dc:language>en-US</dc:language><generator>Telligent Community 13</generator><lastBuildDate>Thu, 02 Mar 2023 17:34:52 GMT</lastBuildDate><atom:link rel="self" type="application/rss+xml" href="https://devzone.nordicsemi.com/f/nordic-q-a/97206/android-ble-library-mtu-change-on-peripheral" /><item><title>RE: Android Ble library MTU change on peripheral</title><link>https://devzone.nordicsemi.com/thread/413105?ContentTypeID=1</link><pubDate>Thu, 02 Mar 2023 17:34:52 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:7aba050e-56fb-41be-b49c-d73dbbe5553e</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Jean Baptiste,&lt;/p&gt;
&lt;p&gt;I see, it looks like the MTU negotiation was indeed successful.&lt;/p&gt;
&lt;p&gt;To have the MTU value updated correctly within a BleManager, you have two approaches:&lt;/p&gt;
&lt;ol&gt;
&lt;li&gt;If you setup a BleServerManager, the BleServerManager will receive the necessary callback and update the MTU value automatically for you.&lt;br /&gt;Here is an example for BleServerManager initialization: &lt;a href="https://github.com/NordicSemiconductor/Android-BLE-Library/blob/55ac0691cfae60e478c0304fb0c0722f2db6299c/examples/trivia/src/main/java/no/nordicsemi/android/ble/trivia/server/repository/ServerManager.kt#L30"&gt;link&lt;/a&gt;.&lt;br /&gt;The BleServerManager&amp;nbsp;must also be added to each BleManager instance; refer to: &lt;a href="https://github.com/NordicSemiconductor/Android-BLE-Library/blob/55ac0691cfae60e478c0304fb0c0722f2db6299c/examples/trivia/src/main/java/no/nordicsemi/android/ble/trivia/server/viewmodel/ServerViewModel.kt#L172"&gt;link&lt;/a&gt;.&lt;br /&gt;&lt;br /&gt;&lt;/li&gt;
&lt;li&gt;In your &lt;span&gt;android.bluetooth.BluetoothGattServerCallback#onMtuChanged()&lt;/span&gt;, you must call &lt;a href="https://github.com/NordicSemiconductor/Android-BLE-Library/blob/v2.3.0/ble/src/main/java/no/nordicsemi/android/ble/BleManager.java#L1731"&gt;BleManager#overrideMtu()&lt;/a&gt;.&lt;/li&gt;
&lt;/ol&gt;
&lt;p&gt;Please try one of the two options and let me know if it helps you.&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Android Ble library MTU change on peripheral</title><link>https://devzone.nordicsemi.com/thread/412897?ContentTypeID=1</link><pubDate>Thu, 02 Mar 2023 07:33:03 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:c70eb251-ad8f-4d9c-99b1-de0415f99e29</guid><dc:creator>Jean-Baptiste</dc:creator><description>&lt;p&gt;Hi Hieu,&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;thank you for your answer,&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;the MTU request&amp;nbsp;and update is reflected in both logs of the app and the&amp;nbsp; nrf :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;RTT traces :&lt;/p&gt;
&lt;p&gt;...&lt;br /&gt;00&amp;gt; [12:00:37] &amp;lt;debug&amp;gt; nrf_ble_gatt: Requesting to update ATT MTU to 245 bytes on connection 0x0.&lt;br /&gt;00&amp;gt; [12:00:37] &amp;lt;debug&amp;gt; nrf_ble_gatt: Updating data length to 249 on connection 0x0.&lt;/p&gt;
&lt;p&gt;...&lt;br /&gt;00&amp;gt; [12:00:38] &amp;lt;debug&amp;gt; nrf_ble_gatt: ATT MTU updated to 245 bytes on connection 0x0 (response).&lt;br /&gt;00&amp;gt; [12:00:38] &amp;lt;info&amp;gt; BLE: The ATT_MTU size was updated to 245 bytes.&lt;br /&gt;...&lt;/p&gt;
&lt;p&gt;APP log :&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1677742094375v1.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;Sniffer :&lt;/p&gt;
&lt;p&gt;&lt;img style="max-height:240px;max-width:320px;" src="https://devzone.nordicsemi.com/resized-image/__size/640x480/__key/communityserver-discussions-components-files/4/pastedimage1677742117631v2.png" alt=" " /&gt;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;
&lt;p&gt;Then from the sniffer trace, we can observe that the transaction from the nrf to the app ( indications or notifications )&amp;nbsp;use correctly the new MTU, but the app using the nordic android library still considers that the mtu has not changed&amp;nbsp;and continue splitting the long packets in small chunks.&amp;nbsp;&lt;/p&gt;
&lt;p&gt;&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item><item><title>RE: Android Ble library MTU change on peripheral</title><link>https://devzone.nordicsemi.com/thread/412836?ContentTypeID=1</link><pubDate>Wed, 01 Mar 2023 19:39:10 GMT</pubDate><guid isPermaLink="false">137ad170-7792-4731-bb38-c0d22fbe4515:cd928655-2286-4227-86c8-da2741b5fbaf</guid><dc:creator>Hieu</dc:creator><description>&lt;p&gt;Hi Jean-Baptiste,&lt;/p&gt;
&lt;p&gt;I am asking our app team regarding your question about the&amp;nbsp;design decision around the tracking of the MTU value. Looks to me that the API expects you to call overrideMtu() on the relevant MTU callbacks.&lt;/p&gt;
&lt;p&gt;Meanwhile, I would like to check if MTU negotiation was actually successful between the devices.&lt;/p&gt;
&lt;p&gt;What are the logs on both the Android side and the nRF52840 side concerning the MTU exchange? Is the result reflected in your sniffer trace?&lt;/p&gt;
&lt;p&gt;On the nRF52840 device, if your application is using the nrf_ble_gatt library, you can enable log level debug for that library and see the result of the negotiation.&lt;br /&gt;If the application is handling the negotiation on its own, then you can log the event data of the SoftDevice event BLE_GATTS_EVT_EXCHANGE_MTU_REQUEST.&lt;/p&gt;
&lt;p&gt;Hieu&lt;/p&gt;&lt;div style="clear:both;"&gt;&lt;/div&gt;</description></item></channel></rss>