下午好 。我正在开发一个应用程序,该应用程序假设通过蓝牙将文件从计算机传输到智能手机,但配对没有按我的预期工作。
与32feets库配对:
BluetoothEndPoint remoteEndPoint = new BluetoothEndPoint(selecteddevice.DeviceAddress,BluetoothService.ObexFileTransfer);
最后一个参数假设为蓝牙适配器 GUID。如果我喂它
蓝牙服务。串行端口。我只能连接到 Iphone SE
蓝牙服务.ObexFileTransfer。我只能与 Allview Soul Xtream Mini 连接。我还有一个 Galaxy Tab 2,我无法以任何方式连接。我使用了一个catch,错误如下:
- ex {“请求的地址在其上下文中无效 4CBCA5CAA8A0:0000110600001000800000805f9b34fb”} System.Net.Sockets.SocketException
我做了一些研究,这就是我发现的: https ://32feet.codeplex.com/wikipage?title=Errors
配对码:
private void Connect()
{
SelectBluetoothDeviceDialog bldialog = new SelectBluetoothDeviceDialog();
serviceClass = BluetoothService.SerialPort;
bldialog.ShowAuthenticated = true;
bldialog.ShowRemembered = true;
bldialog.ShowUnknown = true;
if (bldialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
if (bldialog.SelectedDevice == null)
{
System.Windows.Forms.MessageBox.Show("No device selected", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
return;
}
BluetoothDeviceInfo selecteddevice = bldialog.SelectedDevice;
BluetoothEndPoint remoteEndPoint = new BluetoothEndPoint(selecteddevice.DeviceAddress, BluetoothService.ObexFileTransfer);
client = new BluetoothClient();
try
{
client.Connect(remoteEndPoint);
}
catch (SocketException ex)
{
return;
}
catch (ObjectDisposedException ex)
{
return;
}
catch (IOException ex)
{
return;
}
textBox.Text += string.Format("Connected to: {0}", selecteddevice.DeviceName);
textBox.Text += string.Format("Bluetooth Device Browser. Current Device: {0}", selecteddevice.DeviceName);
}
}
作为蓝牙,我使用的是 ASUS USB-BT400 。 我能做些什么来解决我的连接问题?