I try sending a file using 32feet.Net's Obex library and I get an System.Net.Sockets.SocketException. I have not been able to find any relevant examples and the current documentation is outdated.
Here is my full Exception
System.Net.WebException: Connect failed. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond A0AB51BE1948:0000110500001000800000805f9b34fb
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.Connect(BluetoothEndPoint remoteEP)
at InTheHand.Net.Sockets.BluetoothClient.Connect(BluetoothEndPoint remoteEP)
at InTheHand.Net.ObexWebRequest.Connect()
at InTheHand.Net.ObexWebRequest.GetResponse()
--- End of inner exception stack trace ---
at InTheHand.Net.ObexWebRequest.GetResponse()
at Bluetooth_DualSense.Form1.SendFile(String fileToSend, String destinationPath) in C:\Users\timmy\source\repos\Bluetooth DualSense\Bluetooth DualSense\Form1.cs:line 89
Here is my function to send it.
and, to call...
Here is my full Exception
System.Net.WebException: Connect failed. ---> System.Net.Sockets.SocketException: A connection attempt failed because the connected party did not properly respond after a period of time, or established connection failed because connected host has failed to respond A0AB51BE1948:0000110500001000800000805f9b34fb
at System.Net.Sockets.Socket.DoConnect(EndPoint endPointSnapshot, SocketAddress socketAddress)
at System.Net.Sockets.Socket.Connect(EndPoint remoteEP)
at InTheHand.Net.Bluetooth.Msft.SocketBluetoothClient.Connect(BluetoothEndPoint remoteEP)
at InTheHand.Net.Sockets.BluetoothClient.Connect(BluetoothEndPoint remoteEP)
at InTheHand.Net.ObexWebRequest.Connect()
at InTheHand.Net.ObexWebRequest.GetResponse()
--- End of inner exception stack trace ---
at InTheHand.Net.ObexWebRequest.GetResponse()
at Bluetooth_DualSense.Form1.SendFile(String fileToSend, String destinationPath) in C:\Users\timmy\source\repos\Bluetooth DualSense\Bluetooth DualSense\Form1.cs:line 89
Here is my function to send it.
Sendfile:
public void SendFile(string fileToSend, string destinationPath)
{
string addr = "A0AB51BE1948";
var address = BluetoothAddress.Parse(addr);
try
{
var obexUri = new Uri("obex://" + address + "/" + destinationPath);
var request = new ObexWebRequest(obexUri);
request.ReadFile(fileToSend);
var response = request.GetResponse() as ObexWebResponse;
response.Close();
}
catch (FileNotFoundException e)
{
DialogResult result = MessageBox.Show("Exception thrown: Ex9076\nDo you wish to take actions to resolve this ERROR?", "ERROR", MessageBoxButtons.YesNoCancel);
if (result == DialogResult.Yes)
{
textBox1.Text += Environment.NewLine + "Downloading... " + e.FileName;
textBox1.Text += Environment.NewLine + "Downloaded";
File.Create(e.FileName);
}
else
{
textBox1.Text = "";
for ( int i = 0; i < 10; i++)
{
textBox1.Text += "MISSING: " + e.FileName+ Environment.NewLine;
}
}
}
catch (Exception ex)
{
textBox1.Text += Environment.NewLine+ex;
}
}
and, to call...
Call Script:
SendFile("doyouknowpython.py", Directory.GetCurrentDirectory());