public static IGattCharacteristicWrapper WithReadValueAsyncResult(
            this IGattCharacteristicWrapper characteristic,
            IGattReadResultWrapper result)
        {
            _ = characteristic.ReadValueAsync( )
                .Returns(Task.FromResult(result));

            return(characteristic);
        }
Exemplo n.º 2
0
        private async Task <(bool, byte [])> ReadValue(
            [NotNull] IGattCharacteristicWrapper characteristic)
        {
            Guard.ArgumentNotNull(characteristic,
                                  nameof(characteristic));

            var readValue = await characteristic.ReadValueAsync( );

            ProtocolError = readValue.ProtocolError;
            Status        = readValue.Status;

            if (GattCommunicationStatus.Success != Status)
            {
                return(false, ArrayEmpty);
            }

            return(_reader.TryReadValue(readValue.Value,
                                        out var bytes)
                       ? (true, bytes)
                       : (false, ArrayEmpty));
        }