Comments (15)
Do you have some example for setMaxBatchSize(512 ?
from rxandroidble.
Example from green_android
@Override public int write(final byte[] bytes) { this.disposable.add(this.connection .flatMap(rxConn -> rxConn.createNewLongWriteBuilder() .setMaxBatchSize(512) .setCharacteristicUuid(IO_TX_CHAR_UUID) .setBytes(bytes) .build()) .subscribe(this::onBytesSent, this::onSendFailure) ); return bytes.length; }
from rxandroidble.
The work-around doesn't work in Android 14, using this .setMaxBatchSize(512) shows no effect for me, any solution for this yet?
from rxandroidble.
@sravan-wellnesys keep in mind that this change is for writing to BLE device. Be sure that the BLE device also respect the spec.
from rxandroidble.
@sravan-wellnesys keep in mind that this change is for writing to BLE device. Be sure that the BLE device also respect the spec.
Can you please explain what exactly needs to be done, as I check this https://issuetracker.google.com/issues/307234027, Android 14 is by default requesting MTU 517, So should we update our peripheral device to respond to MTU 517 or By doing what you said .setMaxBatchSize(512) and configure our peripheral device to respond to MTU 512 even if Android 14 requests MTU 517?
Btw, this is what I am getting in logs:
packages/modules/Bluetooth/system/stack/gatt/gatt_api.cc:768 GATTC_TryMtuRequest: **:**:**:**:49:fe conn_id=0x000d 2023-12-05 17:54:21.669 15046-15098 bluetooth com.google.android.bluetooth I packages/modules/Bluetooth/system/stack/gatt/gatt_api.cc:728 GATTC_ConfigureMTU: Configuring ATT mtu size conn_id:13 mtu:517 user mtu 512 2023-12-05 17:54:21.684 15046-15098 bluetooth com.google.android.bluetooth I packages/modules/Bluetooth/system/stack/gatt/gatt_cl.cc:1113 gatt_process_mtu_rsp: Local pending MTU 512, Remote (**:**:**:**:49:fe) MTU 517 2023-12-05 17:54:21.684 15046-15098 bluetooth com.google.android.bluetooth I packages/modules/Bluetooth/system/stack/gatt/gatt_cl.cc:1133 gatt_process_mtu_rsp: MTU Exchange resulted in: 517 2023-12-05 17:54:21.684 15046-15098 bt_btm_ble com.google.android.bluetooth I packages/modules/Bluetooth/system/stack/btm/btm_ble.cc:619 BTM_SetBleDataLength: xx:xx:xx:xx:49:fe, 516
[ERROR:gatt_cl.cc(693)] value.len larger than GATT_MAX_ATTR_LEN, discard
Thanks for your time.
from rxandroidble.
Can you please explain what exactly needs to be done, as I check this https://issuetracker.google.com/issues/307234027, Android 14 is by default requesting MTU 517, So should we update our peripheral device to respond to MTU 517 or By doing what you said .setMaxBatchSize(512) and configure our peripheral device to respond to MTU 512 even if Android 14 requests MTU 517?
Your device should respond to MTU request with the value 517, but the actual payload you send must be 512 bytes at maximum.
If the device sends more that 512 bytes, from my experience, Android will silently drop the packet.
On my case i had to firmware update my BLE device to send max 512 bytes, and my Android app to send max 512 bytes.
Explanation:
MTU size includes the header size. The header can be from 3-5 bytes, but you should not really care about that. The crucial part is not to send more that 512 byte.
From the issue:
A deeper reason is that the Bluetooth Specification allows the maximum size of an ATT attribute to be 512 bytes and the largest command ATT_PREPARE_WRITE_REQ has 5 bytes of header. Hence 512 + 5 = 517.
The packet data itself should never exceed 512 as per the Bluetooth spec.
from rxandroidble.
Can you please explain what exactly needs to be done, as I check this https://issuetracker.google.com/issues/307234027, Android 14 is by default requesting MTU 517, So should we update our peripheral device to respond to MTU 517 or By doing what you said .setMaxBatchSize(512) and configure our peripheral device to respond to MTU 512 even if Android 14 requests MTU 517?
Your device should respond to MTU request with the value 517, but the actual payload you send must be 512 bytes at maximum.
If the device sends more that 512 bytes, from my experience, Android will silently drop the packet.
On my case i had to firmware update my BLE device to send max 512 bytes, and my Android app to send max 512 bytes.
Explanation: MTU size includes the header size. The header can be from 3-5 bytes, but you should not really care about that. The crucial part is not to send more that 512 byte.
From the issue:
A deeper reason is that the Bluetooth Specification allows the maximum size of an ATT attribute to be 512 bytes and the largest command ATT_PREPARE_WRITE_REQ has 5 bytes of header. Hence 512 + 5 = 517.
The packet data itself should never exceed 512 as per the Bluetooth spec.
Thanks a lot for your explanation, Is there a way that I don't send a value in requestMTU?, Do Android 14 still request 517 even if I don't specify a size in request instead of the default 23 bytes.
from rxandroidble.
Thanks a lot for your explanation, Is there a way that I don't send a value in requestMTU?, Do Android 14 still request 517 even if I don't specify a size in request instead of the default 23 bytes.
Just don't call requestMTU at all.
From the issue:
requestMTU(23) has the same effect as not calling requestMTU() at all, in that case the default MTU of 23 bytes will be used.
from rxandroidble.
Thanks a lot for your explanation, Is there a way that I don't send a value in requestMTU?, Do Android 14 still request 517 even if I don't specify a size in request instead of the default 23 bytes.
Just don't call requestMTU at all.
From the issue:
requestMTU(23) has the same effect as not calling requestMTU() at all, in that case the default MTU of 23 bytes will be used.
Yep, I am not receiving any bytes, not using requestMTU at all like you said. No data transfer is happening. So firmware upgrade is the only solution at this point? Btw my peripheral device is using Bluetooth 4.2.
from rxandroidble.
Thanks a lot for your explanation, Is there a way that I don't send a value in requestMTU?, Do Android 14 still request 517 even if I don't specify a size in request instead of the default 23 bytes.
Just don't call requestMTU at all.
From the issue:requestMTU(23) has the same effect as not calling requestMTU() at all, in that case the default MTU of 23 bytes will be used.
Yep, I am not receiving any bytes, not using requestMTU at all like you said. No data transfer is happening. So firmware upgrade is the only solution at this point? Btw my peripheral device is using Bluetooth 4.2.
I think so.
Try using a different android version and see the size of data the device is sending. If it's more than 512, you can be sure that's your issue.
from rxandroidble.
Thanks a lot for your explanation, Is there a way that I don't send a value in requestMTU?, Do Android 14 still request 517 even if I don't specify a size in request instead of the default 23 bytes.
Just don't call requestMTU at all.
From the issue:requestMTU(23) has the same effect as not calling requestMTU() at all, in that case the default MTU of 23 bytes will be used.
Yep, I am not receiving any bytes, not using requestMTU at all like you said. No data transfer is happening. So firmware upgrade is the only solution at this point? Btw my peripheral device is using Bluetooth 4.2.
I think so. Try using a different android version and see the size of data the device is sending. If it's more than 512, you can be sure that's your issue.
I tried with Android 12, When Mtu - 512, I get 509 bytes, when Mtu size - 517, I receive 514 bytes, I thought the max was 512. So app issue or device issue?
from rxandroidble.
I think is device issue that needs a fix with firmware update, the device should not send more than 512 bytes.
from rxandroidble.
I think is device issue that needs a fix with firmware update, the device should not send more than 512 bytes.
So anything more than 512 does not work for Android 14, but works for the previous versions?
from rxandroidble.
So anything more than 512 does not work for Android 14, but works for the previous versions?
Correct, Android 14 is more strict following more strictly the version 5.2 of the Bluetooth Core.
from rxandroidble.
Related Issues (20)
- Permission for connection with sample-kotlin HOT 2
- Wrong permission checked in sample-kotlin app
- Strange unresolved methods HOT 1
- Does RxAndroidBle support the use of Bluetooth Gatt's connect method? HOT 4
- Building fork help HOT 6
- It is not possible to disconnect the Bluetooth while it is in the process of connecting. HOT 1
- BleGattCharacteristicException while readCharacteristic HOT 12
- scanResult.bleDevice.name not showing Ble updated name HOT 1
- BLUETOOTH_SCAN set usesPermissionFlags="neverForLocation",Is there a problem? HOT 2
- GenericFailure<CharacteristicValueUpdateError> HOT 11
- Send long bytes twice HOT 2
- Write request is not processed in the random order HOT 2
- Long Bytes Send HOT 8
- Creating a Fork HOT 2
- Set Preferred PHY / Read PHY HOT 2
- RxBleClient mulit connections HOT 4
- Is the library still maintained? HOT 3
- Google Pixel 5 loses bonding info after BT adapter cycle HOT 4
- Metode readcharacteristic not stream HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
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.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from rxandroidble.