Exemplo n.º 1
0
        public static IObservable <byte[]> WhenReadOrNotify(this IGattCharacteristic character, TimeSpan readInterval)
        {
            if (character.CanNotify())
            {
                return(character.SubscribeToNotifications());
            }

            if (character.CanRead())
            {
                return(character.ReadInterval(readInterval));
            }

            throw new ArgumentException($"Characteristic {character.Uuid} does not have read or notify permissions");
        }
Exemplo n.º 2
0
        public static IObservable <CharacteristicResult> WhenReadOrNotify(this IGattCharacteristic character, TimeSpan readInterval)
        {
            if (character.CanNotify())
            {
                return(character
                       .EnableNotifications()
                       .Where(x => x)
                       .Select(x => character.WhenNotificationReceived())
                       .Switch());
            }

            if (character.CanRead())
            {
                return(character.ReadInterval(readInterval));
            }

            throw new ArgumentException($"Characteristic {character.Uuid} does not have read or notify permissions");
        }