【发布时间】:2015-10-06 14:05:38
【问题描述】:
我正在使用 C# 和 32feet 库编写控制台应用程序。我想通过蓝牙连接到手机设备。我正在关注此代码:link 我在配对两个设备时遇到了一个问题。我正在使用这一行来请求连接:
bool isPaired = BluetoothSecurity.PairRequest(device.DeviceAddress, DEVICE_PIN);
现在我的手机上显示了身份验证请求,但有一个问题,因为手机上的身份验证码与 DEVICE_PIN 略有不同。计算机尝试连接手机,但几分钟后我收到“连接失败”信息。 这是我的配对方法
public void pair(int index)
{
BluetoothClient client = new BluetoothClient();
devices = client.DiscoverDevices();
BluetoothDeviceInfo device = devices[index];
bool isPaired = BluetoothSecurity.PairRequest(device.DeviceAddress, "8080");
if (isPaired)
{
Console.WriteLine("Paired: ");
}
else
{
Console.WriteLine("Not paired: ");
}
}
【问题讨论】:
-
试试:
client.setPin(...)