uwp蓝牙配对,无提示

时间:2018-10-26 13:54:04

标签: uwp bluetooth prompt pairing

由于我当前正在使用Windows设备的自动测试功能,因此我需要使用Windows 10(内部版本10536)的内置库来测试DUT(被测试设备)的蓝牙功能,因为设备在测试之前已恢复出厂设置。 为了进行测试,我制作了自定义的UWP应用来测试设备的不同方面。现在我正在弄乱蓝牙。出于测试目的,我有n个蓝牙(rfComm)设备,并且该设备需要自动连接到选定的蓝牙设备(从其他设备发送,该部分已经开发)。 不需要,我需要参与其中,根据TCP的要求,一个应用程序会扫描未配对的设备,并与某些设备配对(带有ID)。

扫描结果收集在可观察的集合中。

我目前尝试与设备配对:

 public async Task<int> PairWithSelectedAsync(string SSIDToPairWith)
    {
        int returnvalue = 0;
        foreach (RfcommChatDeviceDisplay rfcommInfoDisp in ResultCollection)
        {
            if (rfcommInfoDisp.Id == SSIDToPairWith)
            {
                Debug.WriteLine("Found device to connect to");
                Debug.WriteLine(rfcommInfoDisp.Name);
                Debug.WriteLine(rfcommInfoDisp.Id);
                if(rfcommInfoDisp.DeviceInformation.Pairing.CanPair == true)
                {
                    //rfcommInfoDisp.DeviceInformation.Properties.
                    DevicePairingResult pairingResult= await rfcommInfoDisp.DeviceInformation.Pairing.PairAsync();
                    if(pairingResult.Status == 0)
                    {
                        Debug.WriteLine("Connected");
                        returnvalue = 0;
                    }
                    else
                    {
                        returnvalue = (int)pairingResult.Status;

                    }
                }
                //Debug.WriteLine("\n");
            }
        }
        return returnvalue;
    }

现在的问题是: 这种配对需要用户提示才能继续:弹出窗口出现在屏幕上,操作员需要点击它。是否可以通过不需要与设备配对的提示来修改当前代码?

我也查看了该线程,但似乎该解决方案不适用于“库存”库:Pairing with 32feetnet 同样,This topic似乎已经死了,没有人从那里找到答案。 任何建议或帮助,表示赞赏。

0 个答案:

没有答案