Пример #1
0
        /// <summary>
        /// Command that implements extended write mode to facilitate communications with an ISO 7816-4 based credential to a PD.
        /// </summary>
        /// <summary>Request to get the capabilities of the PD.</summary>
        /// <param name="connectionId">Identify the connection for communicating to the device.</param>
        /// <param name="address">Address assigned to the device.</param>
        /// <param name="extendedWrite">The extended write data.</param>
        /// <returns>Reply data that is returned after sending the command. There is the possibility of different replies can be returned from PD.</returns>
        public async Task <ReturnReplyData <ExtendedRead> > ExtendedWriteData(Guid connectionId, byte address,
                                                                              ExtendedWrite extendedWrite)
        {
            var reply = await SendCommand(connectionId,
                                          new ExtendedWriteDataCommand(address, extendedWrite)).ConfigureAwait(false);

            return(new ReturnReplyData <ExtendedRead>
            {
                Ack = reply.Type == ReplyType.Ack,
                Nak = reply.Type == ReplyType.Nak ? Nak.ParseData(reply.ExtractReplyData) : null,
                ReplyData = reply.Type == ReplyType.ExtendedRead ? ExtendedRead.ParseData(reply.ExtractReplyData) : null
            });
        }
Пример #2
0
 public ExtendedReadReplyEventArgs(Guid connectionId, byte address, ExtendedRead extendedRead)
 {
     ConnectionId = connectionId;
     Address      = address;
     ExtendedRead = extendedRead;
 }
Пример #3
0
        internal virtual void OnReplyReceived(Reply reply)
        {
            {
                var handler = ReplyReceived;
                handler?.Invoke(this, new ReplyEventArgs {
                    Reply = reply
                });
            }

            switch (reply.Type)
            {
            case ReplyType.Nak:
            {
                var handler = NakReplyReceived;
                handler?.Invoke(this,
                                new NakReplyEventArgs(reply.ConnectionId, reply.Address,
                                                      Nak.ParseData(reply.ExtractReplyData)));
                break;
            }

            case ReplyType.LocalStatusReport:
            {
                var handler = LocalStatusReportReplyReceived;
                handler?.Invoke(this,
                                new LocalStatusReportReplyEventArgs(reply.ConnectionId, reply.Address,
                                                                    Model.ReplyData.LocalStatus.ParseData(reply.ExtractReplyData)));
                break;
            }

            case ReplyType.InputStatusReport:
            {
                var handler = InputStatusReportReplyReceived;
                handler?.Invoke(this,
                                new InputStatusReportReplyEventArgs(reply.ConnectionId, reply.Address,
                                                                    Model.ReplyData.InputStatus.ParseData(reply.ExtractReplyData)));
                break;
            }

            case ReplyType.OutputStatusReport:
            {
                var handler = OutputStatusReportReplyReceived;
                handler?.Invoke(this,
                                new OutputStatusReportReplyEventArgs(reply.ConnectionId, reply.Address,
                                                                     Model.ReplyData.OutputStatus.ParseData(reply.ExtractReplyData)));
                break;
            }

            case ReplyType.ReaderStatusReport:
            {
                var handler = ReaderStatusReportReplyReceived;
                handler?.Invoke(this,
                                new ReaderStatusReportReplyEventArgs(reply.ConnectionId, reply.Address,
                                                                     Model.ReplyData.ReaderStatus.ParseData(reply.ExtractReplyData)));
                break;
            }

            case ReplyType.RawReaderData:
            {
                var handler = RawCardDataReplyReceived;
                handler?.Invoke(this,
                                new RawCardDataReplyEventArgs(reply.ConnectionId, reply.Address,
                                                              RawCardData.ParseData(reply.ExtractReplyData)));
                break;
            }

            case ReplyType.ManufactureSpecific:
            {
                var handler = ManufacturerSpecificReplyReceived;
                handler?.Invoke(this,
                                new ManufacturerSpecificReplyEventArgs(reply.ConnectionId, reply.Address,
                                                                       ManufacturerSpecific.ParseData(reply.ExtractReplyData)));
                break;
            }

            case ReplyType.ExtendedRead:
            {
                var handler = ExtendedReadReplyReceived;
                handler?.Invoke(this,
                                new ExtendedReadReplyEventArgs(reply.ConnectionId, reply.Address,
                                                               ExtendedRead.ParseData(reply.ExtractReplyData)));
                break;
            }

            case ReplyType.PIVData:
            {
                var handler = PIVDataReplyReceived;
                handler?.Invoke(this,
                                new PIVDataReplyEventArgs(reply.ConnectionId, reply.Address,
                                                          PIVData.ParseData(reply.ExtractReplyData)));
                break;
            }
            }
        }