Пример #1
0
        public static async Task WriteFidoU2FHidMessageAsync([NotNull] this IHidDevice device,
                                                             FidoU2FHidMessage message, CancellationToken cancellationToken)
        {
            if (device == null)
            {
                throw new ArgumentNullException(nameof(device));
            }

            log.Debug($"Sending U2FHid message {message.Command} on channel 0x{message.Channel:X8} with {message.Data.Count} bytes of data");

            var report  = device.CreateOutputReport();
            var packets = MakeOutputPackets(report.Data.Count, message);

            packets.Item1.WriteTo(report.Data);

            await device.SendOutputReportAsync(report, cancellationToken);

            foreach (var continuation in packets.Item2)
            {
                await device.SendOutputReportAsync(ToOutputReport(device, continuation), cancellationToken);
            }
        }