Ringo
Ringo

Reputation: 3965

Windows phone application bluetooth connect

How can I connect my windows phone device with the other devices by bluetooth using my app in c#? So I can send message to each others using my app too or I can create multiplayer game to play through this bluetooth connection.

Upvotes: 1

Views: 2727

Answers (1)

The following example shows how to create a Bluetooth RFCOMM socket connection to connect your app to a device:

Windows Phone 8 Networking Samples

Basically, you have to create a socket connection with a paired Bluetooth device:

PeerFinder.AlternateIdentities["Bluetooth:PAIRED"] = ""; 
var available_devices = await PeerFinder.FindAllPeersAsync(); 
if (available_devices.Count > 0) 
{            
   PeerInformation pi= // Select the device  
}
StreamSocket socket = new StreamSocket(); 
await socket.ConnectAsync(pi.HostName, "1");

This example was shown in Build 2012 conference. You will find the video of the presentation here:

Windows Phone 8: Networking, Bluetooth, and NFC Proximity for Developers (Build 2012)

http://code.msdn.microsoft.com/wpapps/Windows-Phone-8-Networking-835239c1

Upvotes: 2

Related Questions