i don't know what i am doing wrong here is my code so far but the device doesn't seem to connect .. it just waits and waits and then trouws an exception.. do i have to do something before i can connect.. or what? i am using widcomm stack.. an everything else is runnig right.. except what i sayd above :)
BluetoothRadio[ radios = BluetoothRadio.AllRadios;
BluetoothRadio BTRADIO = BluetoothRadio.PrimaryRadio;
string adress = BTRADIO.LocalAddress.ToString();
string name = BTRADIO.Name;
if (BTRADIO.Mode == RadioMode.PowerOff)
BTRADIO.Mode = RadioMode.Connectable;
BluetoothClient test = new BluetoothClient();
BluetoothDeviceInfo[ devices = test.DiscoverDevices();
BluetoothListener BTLISTNER;
//Console.WriteLine("There were " + arr.Length + " devices found:");
if (BTRADIO.Mode == RadioMode.PowerOff)
BTRADIO.Mode = RadioMode.Connectable;
WriteToTextBox1( "There were " + devices.Length + " devices found:" + '\t' );
WriteToTextBox1("\t" + "tässä");
int port = 1;
foreach (BluetoothDeviceInfo b in devices)
{
WriteToTextBox1("");
WriteToTextBox1(("").PadRight(24, '-'));
WriteToTextBox1("\t" + b.DeviceName);
WriteToTextBox1("\t" + b.ClassOfDevice);
WriteToTextBox1("\t" + b.Connected);
WriteToTextBox1("\t" + b.DeviceAddress);
//WriteToTextBox1("\t" + b.InstalledServices);
WriteToTextBox1("\t" + b.LastSeen);
WriteToTextBox1("\t" + b.LastUsed);
WriteToTextBox1("\t" + b.Remembered);
WriteToTextBox1(("").PadRight(24, '-'));
BluetoothAddress ADDRESS = b.DeviceAddress;
WriteToTextBox1("\t" + ADDRESS.Sap );
WriteToTextBox1("\t" + ADDRESS.Nap );
if ( b.DeviceName == "RemoteDevice" )
{
BluetoothEndPoint ep = new BluetoothEndPoint( ADDRESS, BluetoothService.SerialPort );
if (test.Connected)
{
test.Close();
}
//Try to connect
try
{
test.Connect( ep); //this doesnt work.. it doesnet connect and gives exception thaht widcomm doesn't support sockets..
}
catch (Exception)
{
WriteToTextBox1("ERROR in openig connection");//setLabel("No connect() possible: " + e);
}