Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unity incompatibilities with BLE (repro source included) #440

Open
MattLichter opened this issue Oct 29, 2024 · 2 comments
Open

Unity incompatibilities with BLE (repro source included) #440

MattLichter opened this issue Oct 29, 2024 · 2 comments
Labels

Comments

@MattLichter
Copy link

MattLichter commented Oct 29, 2024

I'm sorry for posting yet another Unity issue. But despite much reading, I'm still having problems with Bluetooth LE and Unity, targeting Windows 11 deployment. I know Unity wasn't your primary target here, but right now 32feet is the pretty much the only good lead that we Unity devs have for BLE on Windows.

I have a minimal project that reproduces the issues I'm seeing, and I'm hoping this helps track down what I'm doing wrong. If we manage to resolve my issues, I'm happy to provide it as a working example in your documentation.

https://github.com/MattLichter/InTheHandTest

I have tried all three runtime combinations, each on its own branch of that repository:

  • Unity project = Mono .NET Framework, 32feet = net462
    • Problems loading WinSDK dependencies
  • Unity project = Mono .NET Framework, 32feet = netstandard2.0
    • PlatformNotSupportedException: Operation is not supported on this platform.
  • Unity project = Mono .NET Standard, 32feet = netstandard2.0
    • PlatformNotSupportedException: Operation is not supported on this platform.

I am using Unity 2022.3.50f1 and InTheHand.BluetoothLE 4.0.37, but have seen the same problems on earlier versions of both.

What I've already tried

I read the following issues but none resolved my problems. I must be missing something.

I have used two different ways to get the DLLs into the project, and I have the same issues either way:

  • Manually pulling them out of the .nupkg file
  • Using a third-party NuGetForUnity asset that does this automatically

I have also written a .NET console app (also in my repro repo) using the netstandard2.0 DLLs. I was hoping the real nuget package manager would pull in the proper native dependencies, but I'm still seeing the same issues with "PlatformNotSupportedException: Operation is not supported on this platform."

I have also looked at this example project, and was able to get it to run. However, that example uses the classic Bluetooth library, not the LE library that I need. https://gitlab.com/jcs-workspace/bluetooth/32feet.Unity.Example

Are there any other approaches I should try? Am I just wrong thinking that BLE will work on Unity for Windows?

@MattLichter MattLichter changed the title Unity incompatibilities (repro source included) Unity incompatibilities with BLE (repro source included) Oct 29, 2024
@peterfoot
Copy link
Member

The .NET Standard libraries will definitely not work as they are merely the public API with no implementation. I'm not a Unity developer myself so I'm not sure what compatibility the runtimes in Unity have but previously the .NET 4.x versions have run under Unity Mono. I'll need to investigate why the WinSDK dependencies don't work - these are required as the bridge between the .NET and Windows runtime SDKs. The Bluetooth Classic API was simpler because for .NET4.x it just uses the Win32 APIs.

@MattLichter
Copy link
Author

@peterfoot Thanks for following up with a definitive answer on the .NET Standard issues. I'll abandon that approach then. Next time I'm back on this, I may give .NET 4.x one final attempt. I'll try to remember to update this thread with whatever I learn.

Thanks again!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

2 participants