예제 #1
0
        public void Init()
        {
            _config    = LabTools.GetConfig <BlueToothDeviceConfig>();
            DeviceType = DeviceType.BlueTooth;

            switch (_config.BluetoothGetType)
            {
            case BluetoothGetType.Pick:
                var deviceInformation = PickDevice();
                if (deviceInformation == null)
                {
                    throw new InvalidDataException("Fail to retrieve device information - is the device turned on? (if so, try pairing it in Windows and try again)");
                }
                _bluetoothDevice = BluetoothDevice.FromDeviceInformation(deviceInformation);

                break;

            case BluetoothGetType.Read:
                _bluetoothDevice = BluetoothDevice.FromBluetoothAddress(ulong.Parse(_config.BluetoothAddress, System.Globalization.NumberStyles.HexNumber));

                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }