ble.net icon indicating copy to clipboard operation
ble.net copied to clipboard

ConnectToDevice does not return

Open alessandrofrancesconi opened this issue 4 years ago • 2 comments

Ble.net version 1.2.1 Android API 28

I have this piece of code. I prepare a cancellation token of 3000ms, then I start the connection to a known device in another thread. I've found that:

  • if the device is reachable, ConnectToDevice() returns successfully
  • if it is not, the function never returns even with the cancellation token!
this.connectToken = new CancellationTokenSource(3000);
this.connectionTask = Task.Run(async () =>
{
    try
    {
        var connection = await this.ble.ConnectToDevice(
                new Guid(d.Address),
                connectToken.Token
        );
        
        if (connection.IsSuccessful()) // <--- not reaching this!
        {

alessandrofrancesconi avatar Jun 09 '20 14:06 alessandrofrancesconi

I see that after 3 seconds this line appears: 06-09 21:55:02.130 D/BluetoothGatt(19579): cancelOpen() - device: 00:13:AA:00:7F:91

But nothing else and the code keeps stuck at ConnectToDevice()

alessandrofrancesconi avatar Jun 09 '20 19:06 alessandrofrancesconi

I'm having the same problem. It seems to be working on iOS, but not on Android. Have you managed to get it working?

christian-strydom avatar Apr 12 '23 16:04 christian-strydom