Пример #1
0
        /// <summary>
        /// Initializes the app context
        /// </summary>
        private async void Init()
        {
            Windows.Devices.Bluetooth.BluetoothAdapter adapter = await Windows.Devices.Bluetooth.BluetoothAdapter.GetDefaultAsync();

            if (adapter == null)
            {
                MessageDialog msg = new MessageDialog("Error getting access to Bluetooth adapter. Do you have a have bluetooth enabled?", "Error");
                await msg.ShowAsync();

                IsPeripheralRoleSupported = false;
                IsCentralRoleSupported    = false;
            }
            else
            {
                IsPeripheralRoleSupported = adapter.IsPeripheralRoleSupported;
                IsCentralRoleSupported    = adapter.IsCentralRoleSupported;
            }

            // Start the dev node watcher
            string[] requestedProperties = {};

            devNodeWatcher =
                DeviceInformation.CreateWatcher(
                    DevNodeBTLEDeviceWatcherAQSString,
                    requestedProperties,
                    DeviceInformationKind.Device);

            devNodeWatcher.Added   += DevNodeWatcher_Added;
            devNodeWatcher.Removed += DevNodeWatcher_Removed;
            devNodeWatcher.Updated += DevNodeWatcher_Updated;

            devNodeWatcher.Start();

            return;
        }
        /// <summary>
        /// Initializes the app context
        /// </summary>
        private async void Init()
        {
            Windows.Devices.Bluetooth.BluetoothAdapter adapter = await Windows.Devices.Bluetooth.BluetoothAdapter.GetDefaultAsync();

            if (adapter == null)
            {
                Debug.WriteLine("Error getting access to Bluetooth adapter. Do you have a have bluetooth enabled?", "Error");
                IsPeripheralRoleSupported = false;
                IsCentralRoleSupported    = false;
            }
            else
            {
                IsPeripheralRoleSupported = adapter.IsPeripheralRoleSupported;
                IsCentralRoleSupported    = adapter.IsCentralRoleSupported;
            }

            // Start the dev node watcher
            string[] requestedProperties =
            {
                BatteryLevelGUID,
                BluetoothDeviceAddress
            };

            devNodeWatcher =
                DeviceInformation.CreateWatcher(
                    DevNodeBTLEDeviceWatcherAQSString,
                    requestedProperties,
                    DeviceInformationKind.Device);

            devNodeWatcher.Added   += DevNodeWatcher_Added;
            devNodeWatcher.Removed += DevNodeWatcher_Removed;
            devNodeWatcher.Updated += DevNodeWatcher_Updated;

            devNodeWatcher.Start();
        }
Пример #3
0
        private async void Init()
        {
            Windows.Devices.Bluetooth.BluetoothAdapter adapter = await Windows.Devices.Bluetooth.BluetoothAdapter.GetDefaultAsync();

            if (adapter == null)
            {
                MessageDialog msg = new MessageDialog("Error getting access to Bluetooth adaptor. Do you have a have bluetooth enabled?", "Error");
                await msg.ShowAsync();

                IsPeripheralRoleSupported = false;
                IsCentralRoleSupported    = false;
            }
            else
            {
                IsPeripheralRoleSupported = adapter.IsPeripheralRoleSupported;
                IsCentralRoleSupported    = adapter.IsCentralRoleSupported;
            }

            // Start the dev node watcher
            string[] requestedProperties =
            {
                BluetoothDeviceAddress
            };

            return;
        }
Пример #4
0
        public BluetoothManager()
        {
            _BluetoothDeviceList = new List <RXBluetoothDevice>();
            _ServiceProviderList = new List <RXRfcommServiceProvider>();
            LEScanner            = new RXBluetoothLEScanner(this);
            RfcommScanner        = new RXBluetoothRfcommScanner(this);
            var adapterTask = Windows.Devices.Bluetooth.BluetoothAdapter.GetDefaultAsync().AsTask();

            adapterTask.Wait();
            Win10Adapter = adapterTask.Result;
        }
Пример #5
0
        /// <summary>
        /// Initializes the app context
        /// </summary>
        private async void Init()
        {
            Log.CreateLog();

            Windows.Devices.Bluetooth.BluetoothAdapter adapter = await Windows.Devices.Bluetooth.BluetoothAdapter.GetDefaultAsync();

            //there is no bluetooth for this device
            if (adapter == null)
            {
                IsPeripheralRoleSupported = false;
                IsCentralRoleSupported    = false;
            }
            else
            {
                IsPeripheralRoleSupported = adapter.IsPeripheralRoleSupported;
                IsCentralRoleSupported    = adapter.IsCentralRoleSupported;
            }


            //check that bluetooth is on or off
            await CheckBluetoothOn();


            // Start the dev node watcher
            string[] requestedProperties =
            {
                BatteryLevelGUID,
                BluetoothDeviceAddress
            };

            devNodeWatcher =
                DeviceInformation.CreateWatcher(
                    DevNodeBTLEDeviceWatcherAQSString,
                    requestedProperties,
                    DeviceInformationKind.Device);

            devNodeWatcher.Added   += DevNodeWatcher_Added;
            devNodeWatcher.Removed += DevNodeWatcher_Removed;
            devNodeWatcher.Updated += DevNodeWatcher_Updated;

            devNodeWatcher.Start();

            return;
        }
Пример #6
0
 internal BluetoothAdapter(Windows.Devices.Bluetooth.BluetoothAdapter adapter)
 {
     _adapter = adapter;
 }