public void ConfigureViewModel()
        {
            var devices = _bluetoothService.GetBondedDevices();

            foreach (var device in devices)
            {
                if (!BluetoothDevices.Any(d => d.Name == device.Name && d.Mac == device.Mac))
                {
                    BluetoothDevices.Add(new BluetoothDevice(device.Name, device.Mac));
                }
            }
        }
示例#2
0
        public void SearchForDevices()
        {
            BluetoothDevices.Clear();
            localEndPoint = new BluetoothEndPoint(CurrentAdapter.LocalAddress, BluetoothService.SerialPort);
            client        = new BluetoothClient(localEndPoint);
            foreach (BluetoothDeviceInfo device in client.DiscoverDevices())
            {
                BluetoothDevices.Add(device);
            }

            if (BluetoothDevices.Any())
            {
                ChosenDevice = BluetoothDevices[0];
            }
            else
            {
                MessageBox.Show("No bluetooth devices were found", "Error", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }
示例#3
0
        public void SearchForDevices()
        {
            // urządzenia znalezione w poprzednim wyszukiwaniu nie muszą być aktywne przy aktualnym wyszukaniu
            BluetoothDevices.Clear();

            // utworzenie endpointu (adres hosta i port usługi (emulacja portu szeregowego))
            localEndPoint = new BluetoothEndPoint(CurrentAdapter.LocalAddress, BluetoothService.SerialPort);
            client        = new BluetoothClient(localEndPoint);

            // przepisanie znalezionych urządzeń za pomocą client.DiscoverDevices() do BluetoothDevice
            foreach (BluetoothDeviceInfo device in client.DiscoverDevices())
            {
                BluetoothDevices.Add(device);
            }

            if (BluetoothDevices.Any())
            {
                ChosenDevice = BluetoothDevices[0];
            }
            else
            {
                MessageBox.Show("Nie znaleziono urządzeń bluetooth", "Błąd", MessageBoxButton.OK, MessageBoxImage.Error);
            }
        }