private void InitializeBt()
{
if (_monitor == null)
{
try
{
_monitor = new BluetoothMonitor();
}
catch
{
// Can't function without a bluetooth radio present so alert the user
Microsoft.Surface.UserNotifications.RequestNotification("Surface Bluetooth", "No Bluetooth Hardware Detected");
return;
}
// Data bind the list control to the current list of available devices
DeviceList.ItemsSource = _monitor.Devices;
// Defines how long a single search pass will last
_monitor.DiscoveryDuration = new TimeSpan(0, 0, 5);
// Defines how long to wait between searches
_monitor.IdleDuration = new TimeSpan(0, 0, 5);
_monitor.DiscoveryStarted += MonitorDiscoveryStarted;
_monitor.DiscoveryCompleted += MonitorDiscoveryCompleted;
// Show the Surface's Bluetooth radio name on screen
RadioNameText.Text = _monitor.RadioFriendlyName;
}
// Starts listening loop for detecting nearby devices
_monitor.StartDiscovery();
}