1 (edited by FedericoBusero 2018-11-29 19:23:17)

Topic: BLE doesn't work on Android if packet larger then 20 bytes

When using RemoteXY on Android using BLE communication, I found that in case the RemoteXY-struct is larger then 15 bytes, the app no longer works. This is related to the 20 bytes packet size of BLE.

Is this normal, or is the system designed to also support bigger structs?

2

Re: BLE doesn't work on Android if packet larger then 20 bytes

Is there any chance that this bug is going to be solved? It is a bug in the Android app: when tansmitting data, the Android app on BLE, the app doesn't split the data in packets of 20 bytes, which is required by the BLE standard (MTU limit). On Android, only the first 20 bytes are being transmitted, on iOS all bytes are being transmitted, but not split up in packets of 20 bytes.

The result is that we can only use 14 usefull bytes in the struct when working on Android in BLE mode!

3

Re: BLE doesn't work on Android if packet larger then 20 bytes

Dear administrator,

When using BLE on Android, there is a bug : the transmission needs to be split into buffers of 20 byes, but the app doesn't do that. The result is that it is not possible to have larger remotexy-structs then 15 bytes.

This looks like easy to fix (just split transmission bytes in chunks). Is there a change that this will be fixed in future?

4

Re: BLE doesn't work on Android if packet larger then 20 bytes

Hello. Which bluetooth module do you use? We do not have similar errors with HC-06, HC-06, HM-10 modules.

5 (edited by FedericoBusero 2019-01-12 13:56:51)

Re: BLE doesn't work on Android if packet larger then 20 bytes

The problem occurs
- with all BLE modules, e.g. HM-10 (but I could also reproduce it using other modules)
- only in Android, on iPhone it works ok
- only BLE, Bluetooth classic works ok

An example is the following

http://remotexy.com/en/editor/3d0ae3fcf … 3003373f5/

This works ok, but if you increase the text edit field with 10 extra characters, the bug appears.

The bug is in the Android app, I guess it is only in specific versions of Android: I use 6.0.1.

The solutions is simple: split up the packets in chunks of 20 bytes just before sending, as the BLE standard prescribes (MTU size 23 bytes). Or increase MTU size depending on the maximum packet size. (+3?)

I would be happy to help you: if you have a test version, I am happy to test it for you.

More information on the Android issue:
https://stackoverflow.com/questions/241 … tes-by-ble

6

Re: BLE doesn't work on Android if packet larger then 20 bytes

I found something new about the BLE packet problem!

So, the bug is that the size of the parameters is limited when using Android and BLE:

What I found is, that the bug only is there when the device has
BLECharacteristic::PROPERTY_WRITE_NR
so when writing in the mode "NO RESPONSE"
only the first 20 bytes are being transmitted
55 16 00 80 74 65 73 74 00 00 00 00 00 00 00 00 00 00 00 00

In case the BLE characterstic is set on
BLECharacteristic::PROPERTY_WRITE
so when writing in the mode "WITH RESPONSE"
the packet is being transmitted fully, e.g.
55 16 00 80 74 65 73 74 00 00 00 00 00 00 00 00 00 00 00 00 48 BA

This means that it works perfectly on Android in mode PROPERTY_WRITE, but on iPhone it only works in mode PROPERTY_WRITE_NR ! This way, it is not possible to write single code for both operating systems.

The solution is very easy, I think: transmit the data in BLE packets of 20 bytes, just split the data in pieces, as the receiver concatenated all the bytes again.

(In case you want to reproduce: make a screen with only an increasing text string: it only works until 14 characters. Using ESP32 BLE ).

I hope this helps in solving the issue.

7

Re: BLE doesn't work on Android if packet larger then 20 bytes

Thanks. We were looking for a solution to this question.
In iOS xcode, there is a need to select write type, and it is .withoutResponse. iOS doesn't work without it.
The Android uses default value if not specify. This is value is different on different devices. Maybe it depends on the BLE module.
We will try to set the definite value .WRITE_TYPE_NO_RESPONSE
Can you send me your email that is used on Android device, I add you to tester list. You would test a new fixed version. Send to our email info@remotexy.com

8

Re: BLE doesn't work on Android if packet larger then 20 bytes

The bug has been fixed in release 4.4.3 for Android