4

I'm trying to get a hold on specific devices by using the PeerFinder class in Windows 8 / Windows Phone 8.

Following the example as shown in the Build presentation: http://channel9.msdn.com/Events/Build/2012/3-047

I got the paired bluetooth devices by using these lines:

PeerFinder.AlternateIdentities["Bluetooth:PAIRED"] = "";

var devices = await PeerFinder.FindAllPeersAsync();

But now I would like to get a list of devices that are connected via bluetooth or maybe even other devices by using a different key in the:

PeerFinder.AlternateIdentities[KEY] = "";

line of code. The MSDN documentation isn't helpful in this case.

la_fusion
  • 461
  • 3
  • 10

1 Answers1

3

Windows Phone 8 bluetooth APIs can really only be used in a few ways (and those are driven by AlternateIdentities):

1) app-to-device / WP8-to-device. This will only work for paired devices. WP8 bluetooth APIs cannot communicate with bluetooth devices that aren't paired to it. As you've discovered AlternateIdentities["Bluetooth:Paired"]="" is the right thing to use for this usecase.

2) app-to-app / WP8-to-WP8. This allows WP8 apps to communicate with the same app on different phones. You specifically need to avoid setting AlternateIdentities for app-to-app to work.

3) app-to-app / WP8-to-Win8. Using specific AlternativeIdentities on both ends it's also possible to get app-to-app to work for WP8-to-Win8. You'll need to set PeerFinder.AlternateIdentities["WindowsPhone"] on Win8 to the WP8 app GUID, and you'll need to add PeerFinder.AlternateIdentities.Add("Windows",GUID) on WP8 to the Win8 app GUID.

There are other AlternateIdentities formats we haven't shared publicly since they don't apply to 3rd party developers. When thinking about usecases for Bluetooth on WP8 focus on app-to-app and app-to-device.

JustinAngel
  • 16,082
  • 3
  • 44
  • 73
  • Ok that's too bad.. I guess I have to find another way of detecting that the phone is currently connected with a bluetooth device. Any advice perhaps? – la_fusion Nov 21 '12 at 10:30
  • I'm not sure what "currently connected" means, but I'm guessing those devices will be paired via bluetooth. There are no alternative APIs for Bluetooth on WP8 other than PeerFinder. – JustinAngel Nov 21 '12 at 21:35
  • With 'currently connected' I mean that you have an active connection with the paired device. For instance playing music through your headset. I've been told by a colleague of you that this isn't possible.. so anyway thanks for the answer! – la_fusion Nov 22 '12 at 07:44
  • @JustinAngel do you have any working example of the 3rd scenario? I haven't been able to achieve that scenario, and I'm afraid that it is not possible because WP8 uses Bluetooth while Win8 is using WiFi-Direct. – anderZubi Mar 22 '13 at 14:58
  • Same request as above. Do you have any working sample for the 3rd scenario? I am trying to connect a Win Phone 8 app to a desktop program but haven't been able to connect. Tried using Peerfinder.Start() [http://stackoverflow.com/a/20831828/174926] but still no good. – atlantis Mar 02 '14 at 18:05