Hi,
I try to connect my pc (Windows 8 with Micro USB Adapter) with my device.
When I use connect method, I have always same error.
I don't undestand what I must write. Any idea ?
I try to connect my pc (Windows 8 with Micro USB Adapter) with my device.
When I use connect method, I have always same error.
private void button1_Click(object sender, EventArgs e)
{
var radio = BluetoothRadio.PrimaryRadio;
Console.WriteLine("* Radio, address: {0:C}", radio.LocalAddress);
Console.WriteLine("Mode: " + radio.Mode.ToString());
Console.WriteLine("Name: " + radio.Name + ", LmpSubversion: " + radio.LmpSubversion);
Console.WriteLine("ClassOfDevice: " + radio.ClassOfDevice.ToString()
+ ", device: " + radio.ClassOfDevice.Device.ToString()
+ " / service: " + radio.ClassOfDevice.Service.ToString());
Console.WriteLine("BluetoothRadio is supported ? " + BluetoothRadio.IsSupported);
Console.WriteLine();
radio.Mode = RadioMode.Discoverable;
Console.WriteLine("Radio Mode now: " + radio.Mode.ToString());
String[] ports = System.IO.Ports.SerialPort.GetPortNames();
foreach(String port in ports){
Console.WriteLine(port);
}
GetSerialPorts();
// Lancer la découverte des Devices
var cli = new BluetoothClient();
BluetoothDeviceInfo[] peers = cli.DiscoverDevices();
foreach (BluetoothDeviceInfo device in peers)
{
System.Console.WriteLine("Name : " + device.DeviceName);
System.Console.WriteLine("Address : " + device.DeviceAddress);
System.Console.WriteLine("SerialPort : " + BluetoothService.SerialPort);
System.Console.WriteLine("Authenticated ? " + device.Authenticated + " Connected ? " + device.Connected);
if ("Desire HD".Equals(device.DeviceName))
{
BluetoothSecurity.PairRequest(device.DeviceAddress, "1234");//Déclenche la demande de connexion
System.Console.WriteLine("Authenticated ? " + device.Authenticated + " Connected ? " + device.Connected);
//device.SetServiceState(BluetoothService.SerialPort,true);
var ep = new BluetoothEndPoint(device.DeviceAddress, BluetoothService.SerialPort);//new Guid("{00001101-0000-1000-8000-00805f9b34fb}")
cli.Connect(ep);
}
}
}
private static void GetSerialPorts()
{
SelectQuery q = new SelectQuery("Win32_SerialPort");
ManagementObjectSearcher s = new ManagementObjectSearcher(q);
foreach (object cur in s.Get())
{
ManagementObject mo = (ManagementObject)cur;
object id = mo.GetPropertyValue("DeviceID");
object pnpId = mo.GetPropertyValue("PNPDeviceID");
Console.WriteLine("DeviceID: {0} ", id);
Console.WriteLine("PNPDeviceID: {0} ", pnpId);
Console.WriteLine("");
}//for
}
}
Console : * Radio, address: 00:15:83:54:04:E1
Mode: Discoverable
Name: E553XXXX, LmpSubversion: 5276
ClassOfDevice: 120104, device: DesktopComputer / service: Network, ObjectTransfer
Le thread '<Sans nom>' (0x1580) s'est arrêté avec le code 0 (0x0).
BluetoothRadio is supported ? True
Radio Mode now: Discoverable
COM3
COM4
COM5
DeviceID: COM3
PNPDeviceID: PCI\VEN_8086&DEV_1E3D&SUBSYS_054A1028&REV_04\3&11583659&0&B3
Name : Desire HD
Address : F8DB7FAB8F08
SerialPort : 00001101-0000-1000-8000-00805f9b34fb
Authenticated ? True Connected ? False
Authenticated ? True Connected ? False
Une exception de première chance de type 'InTheHand.Net.Bluetooth.BlueSoleil.BlueSoleilSocketException' s'est produite dans InTheHand.Net.Personal.dll
Une exception non gérée du type 'InTheHand.Net.Bluetooth.BlueSoleil.BlueSoleilSocketException' s'est produite dans InTheHand.Net.Personal.dll
Informations supplémentaires : Aucune connexion n’a pu être établie car l’ordinateur cible l’a expressément refusée
Sorry, error is in french.I don't undestand what I must write. Any idea ?