-
Notifications
You must be signed in to change notification settings - Fork 582
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
MTU is not updated if requested by the peripheral #293
Comments
Should be fixed with #294 |
I tried 1.4.3 with this and it still doesn't work. My data send method ends with:
I can see the _getMaxDataSize: connection.getMtu: _ in the log every time data is sent but the value printed stays at 23. I even tried to do requestMtu(GATT_MTU_MAXIMUM) (=517) but still nothing. Is there something I've missed? I'm using minSdkVersion 21 in my project. |
Have you requested the MTU before you have executed the above code? Are you sure that your peripheral supports higher MTU? |
@dariuszseweryn Yes, I can see in peripheral devices log that the MTU is degotiated to 158 before the data transfer starts. Here's the relevant portion of it:
as you can see there is limitation of 20 bytes (multiple :DEBUG:onDataReceivedImpl()'s). The other direction supports 158 byte MTU just fine and they arrive to mobile app correctly. |
Could you add logs from the Android OS with |
Unfortunately in the above log there is no indication that
Btw. The
Alternatively you could try to specify |
I'm using Sony Xperia XZ Premium with Android 8.0. I'll try both your suggestions. How does the LongWriteBuilder work in case the MTU is 23 and I set MaxBatchSize(155)? Does it truncate or deal with it internally? |
The library will pass the If one does not specify |
In Android BLE logs I found the following lines: 12-11 15:18:50.872 3522-4021/? E/bt_att: MTU request PDU with MTU size 158 Looks like there is something fishy there... I'll try with another phone and will update this bugreport later. Thanks for your help. |
This issue was about a situation where peripheral initiated MTU change was not correctly handled by the library. Your problem is different though related to MTU as well. Please create a new issue if needed. |
Unfortunately this is not a phone issue, but something in the RxAndroidBle. I created a small sample app using pure android BLE classes and I can get the onMtuChanged callback if and only if I call requestMtu first (android Oreo issue, I created one in Android issue tracker: https://issuetracker.google.com/issues/70542026). However I don't get any when running the similar code via RxAndroidBle. I created a small sample app to demonstrate the issue. If I click the "Test Pure" the MTU change is detected, with "Test Rx" not. It could be something I do with RxAndroidBle (I'm not too fluent with Rx world) but I can't figure out what it would be. Tested on both Samsung Galaxy A3 (8.0) as well as Sony Xperia XZ Premium (8.0) |
@petri-lipponen-suunto are you aware that you did not triggered the MTU change in the above example?
The result of the |
Ah, that might explain it, I'll give it a shot. I assumed that the current MTU (from getMtu()) would be updated regardless, since it is a connection parameter... Tested: That did the trick! adding .subscribe() to it caused it to work. It is a bit counter intuitive that the request is not handled if it is not subscribed, at least for someone without any Rx background... |
Summary
RxBleConnectionImpl
privatemtu
variable is not updated if theMTU
request was initiated by the peripheral deviceLibrary version
1.4.1
Steps to reproduce actual result
1. connect to a peripheral
2. make the peripheral to update MTU (i.e. 56)
3. call the
RxBleConnection.getMtu()
Minimum code snippet reproducing the issue
Requires peripheral action
Actual result
RxBleConnection.getMtu()
returns the default MTU (23)Expected result
RxBleConnection.getMtu()
returns the updated MTU (i.e. 56)https://stackoverflow.com/questions/46732724/how-to-get-larger-mtu-in-rxandroidble
The text was updated successfully, but these errors were encountered: