BLE: unexplained delay while WriteCharacteristic (XE8)
in an App for Andriod an iOS i use TBluetoothLEManager to communicate between mobile and a BLE-Device.
To send data to the BLE-device, i use the code-sequence:
If I send a single command to the BLE-Device, the time between CR_GattCharact.
SetValue and FBLEDevice.WriteCharacteristic is about 200ms.
When I send two command on behind the other, the time to write chracteristics is 3s??
Has anybody an explanation for that?(Android 4.4.2, on iOS this delay do not exist)
I don't understand why this doesn't get fixed, but if you want things to work you need to edit System.Android.Bluetooth.pas (you can simply make a copy of the source file ..\source\rtl\net\System.Android.Bluetooth.pas and put it in your project directory) and change the order of the lines:
in procedure TAndroidBluetoothGattListener.onCharacteristicWrite(gatt: JBluetoothGatt; characteristic: JBluetoothGattCharacteristic; status: Integer);
I see the same problem with Android (7.1.1). I do not see a delay when I run my app on an iOS system.
Is the delay different on a different version of Android? You could try tracing down into the call to write and see where the delay takes place.