BleWinrtDll icon indicating copy to clipboard operation
BleWinrtDll copied to clipboard

Subscribe never finishes

Open brunocoimbrar opened this issue 4 years ago • 3 comments

I have a custom device that I am trying to interact with and using another plugin (for android and ios) I got it to work nicely ( https://assetstore.unity.com/packages/tools/network/bluetooth-le-for-ios-tvos-and-android-26661 ) but now I am trying to get support for Windows too (and especially inside the Unity Editor for quick prototyping).

On the demo scene after selecting my device, the correct service, and the correct characteristic, hitting Subscribe does nothing (by "does nothing" I mean that "if I change it to "block: true" it just freezes the demo scene).

Any idea here?

brunocoimbrar avatar Feb 25 '21 16:02 brunocoimbrar

To further investigate you can install Visual Studio Community with C++ Desktop and UWP components., modify the UUIDs in DebugBle/Program.cs and run the DebugBle program.

If it also freezes there, you can download and run the Microsoft's Bluetooth Low Energy sample and see whether that works out. If the demo works, it should be fixable in this repo.

adabru avatar Apr 15 '21 08:04 adabru

Looking at Demo.cs line 128. This looks like the app could easily get stuck in an infinite loop (on the main thread) if PollData is doing something unexpected like trying to deal with subscribing to a characteristic that isn't subscribable. Guessing the error is here!

{
    BleApi.BLEData res = new BleApi.BLEData();
    while (BleApi.PollData(out res, false))
    {
        subcribeText.text = BitConverter.ToString(res.buf, 0, res.size);
        // subcribeText.text = Encoding.ASCII.GetString(res.buf, 0, res.size);
    }
}

jadware avatar Oct 04 '21 21:10 jadware

This could have been fixed by https://github.com/adabru/BleWinrtDll/pull/25.

adabru avatar Aug 14 '22 12:08 adabru