Jump to content
Sign in to follow this  
pcplayer99

FireMonkey BLE Android BluetoothLE1.GetCharacteristic fail

Recommended Posts

Delphi 10.3.1

 

My steps:

 

1. BluetoothLE1.DiscoverDevices(3000);  Can find device, trigger BluetoothLE1EndDiscoverDevices event.

2. FDevice.DiscoverServices; can get services. I can got a service by: AService := BluetoothLE1.GetService(FDevice, MyService_ID);

3. and then if I call: ACharacteristic := BluetoothLE1.GetCharacteristic(AService, My_Characteristic_ID);  I got nil.

 

-----------

at 3, this method will be ok:

for I := 0 to AService.Characteristics.Count -1 do
  begin
    if Aservice.Characteristics.UUID = My_Characteristic_ID then
    begin
      ACharacteristic := Aservice.Characteristics;
      Break;
    end;
  end;

 

After I do this for loop, ACharacteristic := BluetoothLE1.GetCharacteristic(AService, My_Characteristic_ID); will get the right thing.

 

So, Is it a issue?

Share this post


Link to post
42 minutes ago, pcplayer99 said:

So, Is it a issue?

From the documentation:

 

  http://docwiki.embarcadero.com/Libraries/Rio/en/System.Bluetooth.Components.TBluetoothLE.GetCharacteristic

 

"Warning: You must read the value of the AService.Characteristics property before you call GetCharacteristic. Otherwise, GetCharacteristic returns nil."

 

 

Share this post


Link to post

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now
Sign in to follow this  

×