我正在使用 C# 和 32feet 库编写控制台应用程序。我想通过蓝牙连接到手机设备。我正在关注此代码:链接我在配对两个设备时遇到了一个问题。我正在使用这条线来请求连接:
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: ");
}
}