1

我正在使用 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: ");
            }
        }
4

1 回答 1

0

尝试一一停止计算机上的蓝牙 Windows 服务并进行测试。停止 Windows 服务后,请确保禁用/启用计算机上的蓝牙无线电以使其生效。

于 2018-08-02T10:33:36.933 回答