Bob Baudewyns
Bob Baudewyns

Reputation: 163

Delphi FMX BluetoothLE - Writing Characteristic unsuccessful

I'm writing an application targeting Android and iOS that communicates by BLE with Adafruit Bluefruit LE UART Friend using Nordic UART service and TxD/RxD characteristics.

TxGattCharact: TBluetoothGattCharacteristic;
SelectedDevice: TBluetoothLEDevice;

TxGattCharact.SetValueAsString(myString, True); // UTF8 required
if BluetoothLE1.WriteCharacteristic(SelectedDevice, TxGattCharact) then
  ... // everything just fine
else
  Log('Writing Characteristic denied or unsuccessfull');

I had to split my string into chunks of max 20 characters as BLE rule. This is working 90% of the time However, sometimes, WriteCharacteristic is not successfull

Is there a way to understand the reason and a possible action to prevent this? Can I flush the BLE buffers to clean everything before sending another string?

Thank you in advance for your help

Upvotes: 1

Views: 999

Answers (1)

ByteArts
ByteArts

Reputation: 156

One thing to check for is that the UART is enabled on the Nordic module -- I've run into a problem similar to this because sometimes the UART has gotten disabled somehow. You can use the Nordic Toolbox app (for iOS or Android) to check it. You may also need to check that the device is still connected before trying to write to it (check TBluetoothLEDevice.IsConnected property).

Upvotes: 0

Related Questions