Dear ,
I am using 32Feet.NET version 2.3 and every time I connect to a Bluetooth device from a Windows Mobile 6 Device via serial port , the first time it works fine and I can send data but if disconnect and then try to connect a second , time nothing happens the request just hangs . I would really appreciate if you could shed some light on this issue.
here is the code I wrote
//Connect function
public int ConnectToBluetoothDevice(InTheHand.Net.BluetoothAddress DeviceAddress, Guid Service)
{
try
{
bluetoothClient = new BluetoothClient();
InTheHand.Net.BluetoothEndPoint EndPoint = new InTheHand.Net.BluetoothEndPoint(DeviceAddress, Service);
bluetoothClient.Connect(EndPoint);
}
catch (ObjectDisposedException ode)
{
return ClientClosed;
}
catch (System.Net.Sockets.SocketException socketException)
{
return ConnectSocketException;
}
return ConnectToClientSuccess;
}
public int SendTextToDevice(string TextToSend)
{
if (String.Equals(TextToSend, null))
return SendTextErrorInvalidInputs;
try
{
if (bluetoothClient.Connected)
{
straem = bluetoothClient.GetStream();
steramWriter = new StreamWriter(straem);
steramWriter.Write(TextToSend);
steramWriter.Flush();
}
else
{
return SendTextErrorClientNotConnected;
}
}
catch (System.IO.IOException ioException)
{
return SendTextErrorSndingError;
}
return 0;
}
// Disconnect function
public int DisConnectFromBluetoothDevice()
{
if (BluetoothClient.Equals(bluetoothClient, null))
{
return BluetoothClientNull;
}
else
{
straem.Close();
bluetoothClient.Close();
}
return DisconnectSuccess;
}