public NotificationsViewModel(CharacteristicInfo characteristicInfo)
        {
            _commandRunner = IoC.Get <CommandRunner>();

            _characteristicInfo = characteristicInfo;
            Descriptors         = new List <ClientDescriptorViewModel>();

            var properties = _characteristicInfo.Properties;

            if (properties.HasFlag(GattCharacteristicProperties.Indicate))
            {
                Descriptors.Add(new ClientDescriptorViewModel(GattClientCharacteristicConfigurationDescriptorValue.Indicate, "Indicate"));
            }

            if (properties.HasFlag(GattCharacteristicProperties.Notify))
            {
                Descriptors.Add(new ClientDescriptorViewModel(GattClientCharacteristicConfigurationDescriptorValue.Notify, "Notify"));
            }

            _selectedDisplayFormat = DisplayFormats.FirstOrDefault(x => x.Model == characteristicInfo.NotificationDisplayFormat) ?? DisplayFormats[0];
            if (_selectedDisplayFormat.Model != characteristicInfo.NotificationDisplayFormat)
            {
                _characteristicInfo.NotificationDisplayFormat = _selectedDisplayFormat.Model;
                Task.Run(() => _infoManagerLazy.Value.SaveCharacteristic(_characteristicInfo));
            }
        }
Esempio n. 2
0
        public WriteViewModel(CharacteristicInfo characteristicInfo)
        {
            _characteristicInfo = characteristicInfo;
            _commandRunner      = IoC.Get <CommandRunner>();
            CanWrite            = true;

            _selectedDisplayFormat = DisplayFormats.FirstOrDefault(x => x.Model == characteristicInfo.WriteDisplayFormat) ?? DisplayFormats[0];
        }
Esempio n. 3
0
        public ReadViewModel(CharacteristicInfo characteristicInfo)
        {
            _commandRunner         = IoC.Get <CommandRunner>();
            _characteristicInfo    = characteristicInfo;
            _selectedDisplayFormat = DisplayFormats.FirstOrDefault(x => x.Model == _characteristicInfo.ReadDisplayFormat) ?? DisplayFormats[0];

            DoReadValue(cached: true, hideInConsole: true);
        }