This project has moved. For the latest updates, please go here.

lost connection after a connect

Topics: Bluetooth - BlueSoliel, Bluetooth - Microsoft, Bluetooth - Other, Bluetooth - Stonestreet, Bluetooth - Widcomm/Broadcom
Mar 4, 2013 at 11:03 AM
hello,
when I connect to the bluetooth device, the pc disconnect automatically after the connexion. thus i can't connect to the machine connected with serial in the bluetooth device. this is my code :
string addressBluetooth = "0018b2002ea7";
BluetoothRadio radio;
BluetoothClient BluetoothList= new BluetoothClient();
Guid service= BluetoothService.SerialPort;;
BluetoothDeviceInfo[] bdi = new BluetoothDeviceInfo[10];
BluetoothDeviceInfo BluetoothDevice;
radio = BluetoothRadio.PrimaryRadio;
if (radio != null && radio.Mode == RadioMode.PowerOff)
{
     BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;
}
BluetoothList = new BluetoothClient();
service = BluetoothService.SerialPort;

bdi = BluetoothList.DiscoverDevices();


foreach (BluetoothDeviceInfo bluetooth in bdi)
{
     if (bluetooth.DeviceAddress.ToString().Equals(addressBluetooth.ToUpper()))
     {
           BluetoothDevice= bluetooth;
     }
}
try
{
     BluetoothWin32Authentication authetication = new BluetoothWin32Authentication(Win32AuthCallbackHandler);
     SerialPort = new BluetoothClient();
     SerialPort.Connect(new BluetoothEndPoint(BluetoothDevice.DeviceAddress, service));
}
catch (Exception ex)
{
     MessageBox.Show("can't cconnect : " + ex.Message);
}
            
public static void Win32AuthCallbackHandler(object sender, InTheHand.Net.Bluetooth.BluetoothWin32AuthenticationEventArgs e)
{           
     string address = e.Device.DeviceAddress.ToString();
     MessageBox.Show("Received an authentication request from address " + address);

     e.Pin = "0000";

     e.Confirm = true;
}
anyone can say me what the wrong and how can i repare this


thank you in advance :)
Mar 4, 2013 at 2:10 PM
hi everybody,
i resolved the problem this is the soltion is too simple :
string addressBluetooth = "0018b2002ea7";
BluetoothRadio radio;
BluetoothClient BluetoothList= new BluetoothClient();
Guid service= BluetoothService.SerialPort;;
BluetoothDeviceInfo[] bdi = new BluetoothDeviceInfo[10];
BluetoothDeviceInfo BluetoothDevice;
radio = BluetoothRadio.PrimaryRadio;
if (radio != null && radio.Mode == RadioMode.PowerOff)
{
     BluetoothRadio.PrimaryRadio.Mode = RadioMode.Connectable;
}
BluetoothList = new BluetoothClient();
service = BluetoothService.SerialPort;

bdi = BluetoothList.DiscoverDevices();


foreach (BluetoothDeviceInfo bluetooth in bdi)
{
     if (bluetooth.DeviceAddress.ToString().Equals(addressBluetooth.ToUpper()))
     {
           BluetoothDevice= bluetooth;
     }
}
try
{
     BluetoothWin32Authentication authetication = new BluetoothWin32Authentication(BuetoothDevice.DeviceAddress , /*PIN Code*/ "0000");
     SerialPort = new BluetoothClient();
     SerialPort.Connect(new BluetoothEndPoint(BluetoothDevice.DeviceAddress, service));
}
catch (Exception ex)
{
     MessageBox.Show("can't cconnect : " + ex.Message);
}
but i have another problem similar to this problem.
the connection is established but when i want to connect to my machine the connection is automatically closed

anyone have any idea to resolve the problem??

thank you in advance :)
Mar 4, 2013 at 2:10 PM
Edited Mar 4, 2013 at 2:12 PM
sorry double post
Developer
Mar 5, 2013 at 1:28 PM
I would guess that you are sending some data that the remote device does not like, so it closes the connection. Maybe?
Mar 5, 2013 at 2:37 PM
Edited Mar 5, 2013 at 2:41 PM
alanjmcf wrote:
I would guess that you are sending some data that the remote device does not like, so it closes the connection. Maybe?
the i resolved the problem by changing the code pin (sorry :$)
but I can't connect to the remote device. i don't understand why but when the device is connected on the USB, the connection succed. when i connect it with a bluetooth connection (SerialPort), the connection failed.
i dont understand exactly the problem . but i now that the machine use the "COM" port to connect but me i would like to automate it because he ask me a password.

can i select an existante COM to connect with it??
Mar 5, 2013 at 2:43 PM
Edited Mar 12, 2013 at 10:10 AM
no one have any idea please