Пример #1
0
        public IGattCharacteristicBuilder SetNotification(Action <CharacteristicSubscription> onSubscribe = null, NotificationOptions options = NotificationOptions.Notify)
        {
            this.onSubscribe = onSubscribe;
            if (options.HasFlag(NotificationOptions.Indicate))
            {
                this.properties |= GattProperty.Indicate;
            }

            if (options.HasFlag(NotificationOptions.Notify))
            {
                this.properties |= GattProperty.Notify;
            }

            return(this);
        }
Пример #2
0
        public IGattCharacteristicBuilder SetNotification(Action <CharacteristicSubscription> onSubscribe = null, NotificationOptions options = NotificationOptions.Notify)
        {
            this.onSubscribe = onSubscribe;
            var enc = options.HasFlag(NotificationOptions.EncryptionRequired);

            if (options.HasFlag(NotificationOptions.Indicate))
            {
                this.properties |= enc
                    ? CBCharacteristicProperties.IndicateEncryptionRequired
                    : CBCharacteristicProperties.Indicate;
            }

            if (options.HasFlag(NotificationOptions.Notify))
            {
                this.properties |= enc
                    ? CBCharacteristicProperties.NotifyEncryptionRequired
                    : CBCharacteristicProperties.Notify;
            }

            return(this);
        }