C# PeerFinder.SupportedDiscoveryTypes在WinRT Bluetooth应用程序中不返回任何值?

C# PeerFinder.SupportedDiscoveryTypes在WinRT Bluetooth应用程序中不返回任何值?,c#,bluetooth,windows-store-apps,windows-phone-8.1,C#,Bluetooth,Windows Store Apps,Windows Phone 8.1,我正在尝试通过蓝牙在我的Windows应用商店应用程序和我的Windows Phone之间建立连接。我正在使用一个MSDN蓝牙示例 然而,当我运行该应用程序时,我会收到一条错误消息,上面说“不支持浏览同龄人”。所以我甚至不能扫描配对的蓝牙设备。我查看了代码,发现: public PeerFinderScenario() { this.InitializeComponent(); this.Loaded += OnLoaded; _

我正在尝试通过蓝牙在我的Windows应用商店应用程序和我的Windows Phone之间建立连接。我正在使用一个MSDN蓝牙示例

然而,当我运行该应用程序时,我会收到一条错误消息,上面说“不支持浏览同龄人”。所以我甚至不能扫描配对的蓝牙设备。我查看了代码,发现:

    public PeerFinderScenario()
    {
        this.InitializeComponent();

        this.Loaded += OnLoaded;
        _socketHelper.RaiseSocketErrorEvent += SocketErrorHandler;
        _socketHelper.RaiseMessageEvent += MessageHandler;

        // Scenario 1 init
        _triggeredConnectSupported = (PeerFinder.SupportedDiscoveryTypes & PeerDiscoveryTypes.Triggered) ==
                                     PeerDiscoveryTypes.Triggered;

        _browseConnectSupported = (PeerFinder.SupportedDiscoveryTypes & PeerDiscoveryTypes.Browse) ==
                                  PeerDiscoveryTypes.Browse;

        Window.Current.SizeChanged += Current_SizeChanged;
    }
在执行此初始化调用的运行时,\u browseConnectSupported由于从PeerFinder对象返回的内容而被设置为FALSE。具体来说,PeerFinder.SupportedDiscoveryTypes等于“无”。为什么会发生这种情况?我需要做什么才能在SupportedDiscoveryTypes中获得正确的值?这是舱单申报问题吗?PC范围的蓝牙设置问题

我有一个功能正常的蓝牙狗。我知道这一点,因为我能够与我的Windows Phone正确配对。此外,在我的清单功能部分,我已请求“InternetClientServer”和“邻近性”功能,并添加了蓝牙串行端口声明:

<Capabilities>
  <Capability Name="internetClientServer" />
  <DeviceCapability Name="proximity" />
  <!-- Added Bluetooth serial port capability manually -->
  <m2:DeviceCapability Name="bluetooth.rfcomm">
    <m2:Device Id="any">
      <m2:Function Type="name:serialPort" />
    </m2:Device>
  </m2:DeviceCapability>
</Capabilities>

使用WinRt(Phone 8.1和Windows 8.1)和蓝牙时可能会比较棘手,因为您需要手动添加该功能。将此添加到8.1应用程序的AppManifest:

<Capabilities>  <m2:DeviceCapability Name="bluetooth.rfcomm"> 
<m2:Device Id="any"> 
  <m2:Function Type="name:serialPort" /> 
</m2:Device> 

在手机上,如果你使用的是8.0,你只需要勾选“接近和联网”


此外,请注意,这两个BT设备必须事先配对,否则无法发现。

谢谢。我将其添加到清单中,并确保清单中也有“邻近性”和“internetClientServer”。还是不行。PeerFinder.SupportedDiscoveryTypes仍然返回为“无”。