How to use Bluetooth in C#/.net?

I’m trying to do an UI with C# on Visual Studio (on PC[windows10]) and connect some bluetooth devices. I’m using Windows.Devices.Radios & Windows.Devices.Bluetooth, but I have some troubles with that. After few steps I try to use the bluetooth when I press a button. This is the code

        private async void btnStart_ClickAsync(object sender, EventArgs e)     {         Repl test = new Repl();          var radio = await Radio.RequestAccessAsync();         if (access != RadioAccessStatus.Allowed)         {             return;         }         BluetoothAdapter adapter = await BluetoothAdapter.GetDefaultAsync();         if (null != adapter)         {             var btRadio = await adapter.GetRadioAsync();             if (bluetoothState)             {                 await btRadio.SetStateAsync(RadioState.On);             }             else             {                 await btRadio.SetStateAsync(RadioState.Off);             }         }         string connect = $"connect {macRight}\r\n";         //string start = "start\r\n";          await BaseCommands.repl.ParseLine(connect);      } 

after the 1st request I’m always in the "return;" I saw some people saying use x32 or x64 and x86. I already try that but I don’t know why it doesn’t work for me … I also saw some post saying change something in the Manifest, but I don’t know where to find it :/ I’m a beginner with C#/.NET so if someone can help me to fix that i will appreciate =) PS : I have another project which use bluetooth and it work perfectly so I have no ideas to fix my own project …

Add Comment
0 Answer(s)

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.