Is NFC necessary to use Peerfinder?

我是研究僧i 提交于 2019-12-10 21:21:16

问题


In a Windows Store application, I am attempting to use the PeerFinder class to locate the Bluetooth enabled devices around me, but I get an generic exception every time I call Peerfinder.FindAllPeersAsync():

One or more errors occurred while processing the request. (Exception from HRESULT: 0x80070306)

I think the issue is what Peerfinder.SupportedDiscoveryTypes == PeerDiscoveryTypes.None, but I'm not sure why this is. My computer does not have an NFC radio, but it does have Bluetooth. I would have thought this would make Peerfinder.SupportedDiscoveryTypes == PeerDiscoveryTypes.Browse. Is NFC required for this to work?

I have made almost identical code work in Windows Phone 8, but that does have NFC (though I only need to use it the first time to devices are connecting; they remember each other every time after that).

Update:

Here is some more info that people were asking for in the comments:

1) AllowBluetooth == true.
2) Bluetooth is enabled (and I connected something to the PC via Bluetooth just to prove to myself that the radio is working).
3) Both the Proximity and the Networking capabilities have been added.


回答1:


There is an extended example of how to use this here. It appears you can use WiFi on some devices, but if SupportedDiscoveryTypes == PeerDiscovertyTypes.None then none of the above is available. See here for more notes on how to use FindAllPeers.

You can use the SupportedDiscoveryTypes property to determine whether the current PC has a working proximity device or whether the Wi-Fi device supports Wifi-Direct browsing.

Example check from the link:

if ((Windows.Networking.Proximity.PeerFinder.SupportedDiscoveryTypes &
     Windows.Networking.Proximity.PeerDiscoveryTypes.Browse) !=
     Windows.Networking.Proximity.PeerDiscoveryTypes.Browse)
{
    WriteMessageText("Peer discovery using Wifi-Direct is not supported.\n");
    return;
}



回答2:


It seems that Windows 8 devices rely on WiFi Direct to stablish the socket connection, while WP8 devices use Bluetooth. I know that using an NFC-enabled Windows 8 tablet, you can trigger the connection by doing a tap gesture (see the PixPresenter code sample implementing this technique). See also the official documentation samples. However, one would expect that you can connect a Windows Sotre app and a WP8 app using Bluetooth.

MSDN documentation suggest that by using PeerFinder.AlternateIdentities you can tell each app the ID of the app running on the other device.

Here's another article on the subject http://msdn.microsoft.com/en-us/library/windows/apps/jj207060.aspx

Hope this helps.



来源:https://stackoverflow.com/questions/13793342/is-nfc-necessary-to-use-peerfinder

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!