public static IGattCharacteristicWrapper WithWriteValueWithResultAsync(
            this IGattCharacteristicWrapper characteristic,
            IGattWriteResultWrapper result)
        {
            _ = characteristic.WriteValueWithResultAsync(Arg.Any <IBuffer> ( ))
                .Returns(Task.FromResult(result));

            return(characteristic);
        }
示例#2
0
        public async Task <IGattWriteResultWrapper> TryWriteWithoutResponseAsync(
            [NotNull] IGattCharacteristicWrapper characteristic,
            [NotNull] IBuffer buffer)
        {
            Guard.ArgumentNotNull(characteristic,
                                  nameof(characteristic));
            Guard.ArgumentNotNull(buffer,
                                  nameof(buffer));

            if (SupportsWriteWithoutResponse(characteristic))
            {
                var message = $"GattCharacteristic '{characteristic.Uuid}' " +
                              "doesn't support 'Write/WritableAuxiliaries/" +
                              "WriteWithoutResponse'";

                Log.Information(message);

                return(GattWriteResultWrapper.NotSupported);
            }

            var status = await characteristic.WriteValueWithResultAsync(buffer);

            return(status);
        }