inthehand / 32feet

Personal Area Networking for .NET. Open source and professionally supported
https://inthehand.com/components/32feet/
MIT License
821 stars 205 forks source link

BluetoothSecurity.PairRequest issue in InTheHand.Net.Bluetooth V4 #87

Open juliokele opened 4 years ago

juliokele commented 4 years ago

After BluetoothSecurity.PairRequest with result=true, paired device in Windows10 Bluetoothmanager not shown. Aftert that: BluetoothSecurity.RemoveDevice result = false. Pairing with BluetoothAuthenticationMethod.NumericComparison, NumericComparison on target device not shown.

juliokele commented 4 years ago

any news on this?

peterfoot commented 4 years ago

For NumericComparison the handler should be echoing back whatever code was received and so automatically approving it. I'll need to run some more tests. What type of device are you pairing with?

juliokele commented 4 years ago

in V3 mostly works, but not always, process hangs infinitely at this point: https://github.com/inthehand/32feet/blob/a3d464e7825f7ed9b458bdcc5755c2fe6bf2ea00/Legacy/InTheHand.Net.Personal/Net.Bluetooth.Msft/WindowsBluetoothSecurity.cs#L282

Thats why i switched to V4...

Device is a custom device with ESP32 Chip on + SPP_INITIATOR_DEMO firmware. Pairing with Windows 10 (Version: 2004, Build: 19041.572) built in Bluetooth Manager works without any problems

subodhpathak commented 3 years ago

Hi,

Interested to know if this issue is fixed in 4.20. I am trying to do Pairing in an ASP.Net Core application and Pairing Pin dialog does not appear. It is working fine in InTheHand.Net.Personal 3.5. Using two laptops for pairing.

isPaired = BluetoothSecurity.PairRequest(deviceInfo.DeviceAddress, "123456"); <= Pin dialog works fine in old library but not in latest one.

BluetoothClient client = new BluetoothClient If I try to set client.Authenticate = true it throws null exception.

Not sure if I am missing any steps here or the issue listed here is same as what I am getting.

Any help is much appreciated.

JkPersson commented 2 years ago

I am seeing the same on Android (12) and MAUI.

IReadOnlyCollection<BluetoothDeviceInfo> bluetoothDeviceInfos = bluetoothClient.DiscoverDevices(); BluetoothDeviceInfo frameworkDevice = bluetoothDeviceInfos.FirstOrDefault(x => x.DeviceAddress.ToString("C") == MACAddress); if (frameworkDevice == null) { await Shell.Current.DisplayAlert("Pair", "Device is not available", AppResources.Close); return; } bool paired = true; if (!frameworkDevice.Authenticated) { paired = BluetoothSecurity.PairRequest(frameworkDevice.DeviceAddress, Pin); }

PairRequest return true, but the device is not paired. Same call with Pin=null does not trigger the Pairing Pin dialog. I have the following Bluetooth permission set for the app:

<uses-permission android:name="android.permission.BLUETOOTH" />
<uses-permission android:name="android.permission.BLUETOOTH_ADMIN" />
<uses-permission android:name="android.permission.BLUETOOTH_SCAN" />
<uses-permission android:name="android.permission.BLUETOOTH_CONNECT" />
Pyroa commented 1 year ago

Same issue here !

With MAUI .Net 6.0 and Android 12 SKQ1.210908.001 on MUI 13.0.11 Trying to pair a HC-06 device.

It's working to pairing the device manually.