Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
Sample Bluetooth printing from Unity
var devices = DeviceInformation.FindAll(RfcommDeviceService.GetDeviceSelector(RfcommServiceId.SerialPort));
var deviceInfo = devices[0]; // this makes some assumptions about your paired devices so really the results should be enumerated and checked for the correct device
var device = BluetoothDevice.FromDeviceInformation(deviceInfo);
var serResults = device.GetRfcommServices(BluetoothCacheMode.Cached);
foreach(RfcommDeviceService serv in serResults.Services)
if(serv.ServiceId == RfcommServiceId.SerialPort)
var stream = serv.OpenStream();
byte[] buff = System.Text.Encoding.ASCII.GetBytes("Testing\r\n");
stream.Write(buff, 0, buff.Length);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment