Giter Club home page Giter Club logo

Comments (10)

remonh87 avatar remonh87 commented on June 16, 2024

This is not a bug in the library but it what actually happens is that you request an MTU with value x and the phone ble negotiates with the peripheral on this value. Apparently they couldn't honor your request and decided to go for 500 as a compromise (android default).

from flutter_reactive_ble.

riccardocescon avatar riccardocescon commented on June 16, 2024

This is not a bug in the library but it what actually happens is that you request an MTU with value x and the phone ble negotiates with the peripheral on this value. Apparently they couldn't honor your request and decided to go for 500 as a compromise (android default).

Thank you for your response!
Shouldn't i be able to decide how much MTU i want to use in a comunication, or at Least, decide which Is my maximum in case i don't want ti limit It?
If i go into debug mode on my custom ble device on the Gatt handler callback, i Always the MTU request for 247. Then i decided to ask for a MTU of 128 from flutter Just to see if i am receiving the right value on the device, but still i get 247. I then captured the packages to see what was happening i saw that the Android phone asked for 517, but i was expecting 128 instead. So, Is Android changing that value to am higher value Just because It sees It can be higher? Does he basically ignores my MTU request value?
Again, thank you a lot for your hard work for this library!

from flutter_reactive_ble.

riccardocescon avatar riccardocescon commented on June 16, 2024

Hi @remonh87 ,
today i tested again with a different BLE peripheral device and found out that with both Android and iOS i am getting a weird value.
I then used the nrf Connect app to connect to my BLE device, and i set the MTU to 123 and managed to get that value on my peripheral. Then i tried again to use my app, and when i am calling the function 'requestMTU(deviceId, mtu: 123)' the peripheral receives 500 (android default as you said) and not 123 as the function requested.
So basically by using an external app and setting the MTU i am able to get the right value, meanwhile using this library i am always getting the default value and not the one passed to the function.
Is it possible that there is an issue on the library?
Again, thank you a lot for your effort on this package!

Update: still having this issue with the last release: 5.2.0

from flutter_reactive_ble.

riccardocescon avatar riccardocescon commented on June 16, 2024

Hi @remonh87 ,
i searched a bit and found out that the issue may be present on the connectionResult.rxConnection.requestMtu(size) call inside ReactiveBleClient.kt. I found this issue dariuszseweryn/RxAndroidBle#843 that is not relevent to this one, but maybe there is something on the native librareis? could it be this the issue?

from flutter_reactive_ble.

angelix avatar angelix commented on June 16, 2024

Your issue is related to Android 14 breaking changes, Keep in mind that it may even require a firmware update if the device is not handling the MTU negotiation correctly.

In our case, we had to perform a firmware update to set the maximum packet size to 512 bytes. Packages larger than this will be silently dropped by the operating system.

Google issue: https://issuetracker.google.com/issues/307234027

from flutter_reactive_ble.

riccardocescon avatar riccardocescon commented on June 16, 2024

Thank you a lot @angelix for your answer!
I understood this issue caused by Android 14, but i am having this weire MTU Exchange with iOS too, even if i am requesting a smaller MTU, in the example above i have used 123 but from the wireshark capture we can see that Android 14 Is asking for 517 and not 123, isn't that the same issue since i am not requesting for AN higher value?
I am developing the firmware for the peripherical, but i am never be able to get the requested MTU from the app, but i Always receive that 517 whatever i request for, isn't this a different issue?

from flutter_reactive_ble.

angelix avatar angelix commented on June 16, 2024

Your peripheral device should respond to the Android device's MTU request with a reasonable value that can be accommodated by the peripheral. The final negotiated value will be a minimum of the Android requested value and the remote provided value (i.e. min(517, remoteMtu))

Even if you request a smaller MTU with requestMtu(), Android 14 is requesting 517. It's up to the device to respond with a reasonable value.

from flutter_reactive_ble.

riccardocescon avatar riccardocescon commented on June 16, 2024

Your peripheral device should respond to the Android device's MTU request with a reasonable value that can be accommodated by the peripheral. The final negotiated value will be a minimum of the Android requested value and the remote provided value (i.e. min(517, remoteMtu))

Even if you request a smaller MTU with requestMtu(), Android 14 is requesting 517. It's up to the device to respond with a reasonable value.

Thank you for your answer!
I see the issue, but still i think there is something weird on the library.
I have just tried with an Iphone 14 with iOS 17.
I requested an MTU of 123 but the negotiation ended up with 244, this should not be possible, so i think there is an issue on this library too, because the final negotiated MTU cannot be higher than the one i have asked to right? Even if the Iphone supports 512 and i ask for 123, i should not have an MTU higher than the 123, at least i expect to have it equal or lower. Am i missing something or there is an actual issue on the requestMTU method on this package?

from flutter_reactive_ble.

weliem avatar weliem commented on June 16, 2024

There is no method in CoreBluetooth to request a specific MTU. iOS always requests 517...or some other number like 248....depends on the iOS version

from flutter_reactive_ble.

riccardocescon avatar riccardocescon commented on June 16, 2024

There is no method in CoreBluetooth to request a specific MTU. iOS always requests 517...or some other number like 248....depends on the iOS version

I see, thank you!

from flutter_reactive_ble.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.