Help wanted - Bluetooth pairing from Windows #387
Unanswered
samsharp99
asked this question in
Q&A
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Please go easy on me as I am not a C# programmer, but instead program in LabVIEW (a graphical programming language). I am trying to work out how to pair Bluetooth devices (most likely Android, but other Windows/iOS devices would be great too) from Windows.
I am struggling to find a working, up-to-date example - many of the examples/questions I've found are based on older version(s) of the library and the methods/techniques employed seem to no longer be available in newer versions of the InTheHand library.
I am trying to build up a C# WPF test application that can discover devices, pair to them and then communicate (like a terminal/console) over a bluetooth socket.
I can call the 'PairRequest' method and I can see it triggers a pairing request on my other device and it always returns that the pairing was successful, but if I pair in this way, I cannot communicate/open a socket to the other device. If I pair manually, the communication works successfully.
I don't quite understand how the supplied 'PIN' in the PairRequest method works, it doesn't match the pin that appears on the target device and I don't know how to handle the handshaking to agree/share a common PIN.
In the examples I'm finding, I'm seeing references to SetPin, references to BluetoothWin32Authentication and attaching an event callback to BluetoothSecurity.PairRequest, but none of these methods/references seem to be available.
This is my current code, with some commented out functionality that doesn't work (or seem to exist):
`
private async void Pair_Click(object sender, EventArgs e)
{
BluetoothDeviceInfo selected = devices.ElementAt(dataGridView1.SelectedRows[0].Index);
`
I would appreciate any input or pointers to some documentation on how to successfully pair devices on Windows. My goal is to trigger and handle the pairing request programmatically (i.e. for a kiosk/shell type application).
Beta Was this translation helpful? Give feedback.
All reactions