0

I've created a test application with Bluetooth Low Energy (BLE) to perform pooling on the BLE device every 500ms, sending request and receiving response. The BLE device has a "Characteristic" with "Read, Write and Notify Descriptors". After signing in to BLE, an Subscribe is executed on that "Characteristic" via CurrentBLEDevice.SetCharacteristicNotification. The value of "Characteristic" is read in the CurrentBLEDevice.OnCharacteristicRead event (where OnCharacteristicRead = DidCharacteristicRead). Everything works fine until the CurrentBLEDevice.OnCharacteristicRead event stops responding for no reason. (Delphi 10.2.1, Android 5.0).

I have not been able to simulate the error yet and would like to know if there is any test I can do to simulate or fix error.

procedure DidCharacteristicRead(const Sender: TObject;
  const ACharacteristic: TBluetoothGattCharacteristic;
  AGattStatus: TBluetoothGattStatus);
var FCharactValueGet: TBytes;
begin
   if AGattStatus <> TBluetoothGattStatus.Success then Exit;

   FCharactValueGet:= [];
   FCharactValueGet := ACharacteristic.Value;
end;
wBB
  • 821
  • 1
  • 18
  • 39
  • Does this help at all? https://stackoverflow.com/questions/25865587/android-4-3-bluetooth-ble-dont-called-oncharacteristicread – Dave Nottage Sep 27 '18 at 00:50
  • Although it is written in Java, the code you pointed out is very similar to my Delphi code. However, in Delphi, there is no "onCharacteristicChanged". Another difference is the solution suggested in Java is necessary to set the notification in the "Descriptor" and then execute a "Subscribe" in the "Characteristic", but in my case the whole process was already complete and working. Nevertheless, the automatic notification process (which occurs in the `OnCharacteristicRead` event in Delphi) simply stops its operation for no reason after few minutes. Thanks! – wBB Sep 27 '18 at 01:51
  • I was referring mostly to the requirement of calling ReadCharacteristic, which you don't mention, or show in your code – Dave Nottage Sep 27 '18 at 03:18
  • I didn't really mention it, you're right to ask me. But I had already tried using this forced reading using `ReadCharacteristic` and it also did not work. Now I'm working on another hypothesis, but I have not yet fitted my hardware to test. I'm going to force BLE to send some information continuously, but the app will no longer perform pooling. That way I'll know if the `OnCharacteristicRead` event really works or if it doesn't work because there is nothing to respond, since the app is not sending anything that needs to be answered. Thank you again. – wBB Sep 27 '18 at 04:10

0 Answers0