Пример #1
0
        private async Task PlatformStartNotifications()
        {
            Uap.GattClientCharacteristicConfigurationDescriptorValue value = Uap.GattClientCharacteristicConfigurationDescriptorValue.None;
            if (_characteristic.CharacteristicProperties.HasFlag(Uap.GattCharacteristicProperties.Notify))
            {
                value = Uap.GattClientCharacteristicConfigurationDescriptorValue.Notify;
            }
            else if (_characteristic.CharacteristicProperties.HasFlag(Uap.GattCharacteristicProperties.Indicate))
            {
                value = Uap.GattClientCharacteristicConfigurationDescriptorValue.Indicate;
            }
            else
            {
                return;
            }

            try
            {
                var result = await _characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(value);
            }
            catch (UnauthorizedAccessException)
            {
                // not supported
            }
            return;
        }
Пример #2
0
        private async Task DoStartNotifications()
        {
            Uap.GattClientCharacteristicConfigurationDescriptorValue value = Uap.GattClientCharacteristicConfigurationDescriptorValue.None;
            if (_characteristic.CharacteristicProperties.HasFlag(Uap.GattCharacteristicProperties.Notify))
            {
                value = Uap.GattClientCharacteristicConfigurationDescriptorValue.Notify;
            }
            else if (_characteristic.CharacteristicProperties.HasFlag(Uap.GattCharacteristicProperties.Indicate))
            {
                value = Uap.GattClientCharacteristicConfigurationDescriptorValue.Indicate;
            }
            else
            {
                return;
            }

            var result = await _characteristic.WriteClientCharacteristicConfigurationDescriptorAsync(value);

            return;
        }