سؤال

I have a task to communicate with a Bluetooth device (which is not Low Energy - BLE) from a Windows Phone 8 App and latter from Surface App.

I came across this link http://msdn.microsoft.com/en-us/library/windowsphone/develop/jj207007(v=vs.105).aspx which does mention about Bluetooth integration, however it doesn't clearly says if this is for only BLE devices or not?

Please can someone point me to a code sample which I can use to interface (send and receive) data from Bluetooth device. Esp, a RFCOMM e.g., if possible

Really appreciate.

هل كانت مفيدة؟

المحلول

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)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top