2

is it possible to use bluetooth low energy (ble) with .Net (C#) in an console app? For Example like with windows.devices.bluetooth in uwp apps.

I would just do it in uwp, but I need vJoy which is designed for .Net and the MbientLab Metawear C hardware as sensor with ble.

Gogatsu
  • 31
  • 1
  • 1
  • 3

1 Answers1

9

You can use C# APIs in C# Desktop applications! I have a sample here in GitHub.

In general, to get access to the C# APIS, add two references to your project:

  1. C:\Program Files (x86)\Windows Kits\10\UnionMetadata\Windows.winmd
  2. C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework.NETCore\v4.5\System.Runtime.WindowsRuntime.dll

Note that the #2 version depends on the version of .Net that you're using.

Background tasks will not be supported, but all other Bluetooth C# features should be there.

Carter
  • 3,053
  • 1
  • 17
  • 22
  • 1
    What are background tasks? Is it possible to connect and communicate with BLE devices? The sample only shows how to receive advertisements. – Jack Miller Mar 06 '18 at 08:24
  • Ya, but is there a cross platform solution? https://github.com/nexussays/BLE.net That covers a couple additional platforms, but not linux – Doug Beard Aug 15 '19 at 13:15