Jan 18, 2012 at 8:41 PM
Edited Jan 18, 2012 at 8:42 PM
I am writing a Windows Forms application in C# to connect a Windows 7 computer with an Android device over Bluetooth.
I am able to have the user select a device with which to start a connection, but first I would like to be able to ensure the Android device is paired with the computer.
Making use of InTheHand.Windows.Forms.SelectBluetoothDeviceDialog, I have the user select a device from a list of visible devices:
SelectBluetoothDeviceDialog sbtdd = new SelectBluetoothDeviceDialog();
sbtdd.ShowAuthenticated = true;
sbtdd.ShowRemembered = true;
sbtdd.ShowUnknown = true;
Now, I get the device that has been selected by the user:
if (sbtdd.ShowDialog() == DialogResult.OK)
_addr = sbtdd.SelectedDevice.DeviceAddress;
_deviceName = sbtdd.SelectedDevice.DeviceName;
I would like to be able to get the paired status of the device. I know I can start a pairing request using InTheHand.Net.Bluetooth.BluetoothSecurity.PairRequest like this:
This PairRequest method will send a pairing request to the device with Bluetooth address _addr if the device is not already paired, but won't do anything if the device
is already paired. I want to be able to tell the user the PIN, but only if there is going to be a pair request. My problem is that I don't know whether or not the device is paired until I run the PairRequest, but I need to know that info
strictly before the request, so that I can optionally alert the user of the request PIN.
I know I can get some information about the selected device (Authenticated, Connected, Remembered), but is there any way to get the paired status of a device? Maybe I'm just thinking about this wrong...
Thank you in advance for any direction,