internal NAKException(Reply reply) { var nak = Nak.ParseData(reply); ErrorCode = nak.ErrorCode; ErrorString = nak.ErrorString; ExtraData = nak.ExtraData; }
/// <summary> /// Send a command to alter the state of one or more outputs on a 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="outputControls">Data for one or more outputs to control.</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 <OutputStatus> > OutputControl(Guid connectionId, byte address, OutputControls outputControls) { var reply = await SendCommand(connectionId, new OutputControlCommand(address, outputControls)).ConfigureAwait(false); return(new ReturnReplyData <OutputStatus> { Ack = reply.Type == ReplyType.Ack, Nak = reply.Type == ReplyType.Nak ? Nak.ParseData(reply.ExtractReplyData) : null, ReplyData = reply.Type == ReplyType.OutputStatusReport ? Model.ReplyData.OutputStatus.ParseData(reply.ExtractReplyData) : null }); }
/// <summary> /// Send a manufacture specific command to a 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="manufacturerSpecific">The manufacturer specific 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 <ManufacturerSpecific> > ManufacturerSpecificCommand(Guid connectionId, byte address, Model.CommandData.ManufacturerSpecific manufacturerSpecific) { var reply = await SendCommand(connectionId, new ManufacturerSpecificCommand(address, manufacturerSpecific)).ConfigureAwait(false); return(new ReturnReplyData <ManufacturerSpecific> { Ack = reply.Type == ReplyType.Ack, Nak = reply.Type == ReplyType.Nak ? Nak.ParseData(reply.ExtractReplyData) : null, ReplyData = reply.Type == ReplyType.ManufactureSpecific ? ManufacturerSpecific.ParseData(reply.ExtractReplyData) : null }); }
/// <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 }); }
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))); break; } case ReplyType.LocalStatusReport: { var handler = LocalStatusReportReplyReceived; handler?.Invoke(this, new LocalStatusReportReplyEventArgs(reply.ConnectionId, reply.Address, Model.ReplyData.LocalStatus.ParseData(reply))); break; } case ReplyType.InputStatusReport: { var handler = InputStatusReportReplyReceived; handler?.Invoke(this, new InputStatusReportReplyEventArgs(reply.ConnectionId, reply.Address, Model.ReplyData.InputStatus.ParseData(reply))); break; } case ReplyType.OutputStatusReport: { var handler = OutputStatusReportReplyReceived; handler?.Invoke(this, new OutputStatusReportReplyEventArgs(reply.ConnectionId, reply.Address, Model.ReplyData.OutputStatus.ParseData(reply))); break; } case ReplyType.ReaderStatusReport: { var handler = ReaderStatusReportReplyReceived; handler?.Invoke(this, new ReaderStatusReportReplyEventArgs(reply.ConnectionId, reply.Address, Model.ReplyData.ReaderStatus.ParseData(reply))); break; } case ReplyType.RawReaderData: { var handler = RawCardDataReplyReceived; handler?.Invoke(this, new RawCardDataReplyEventArgs(reply.ConnectionId, reply.Address, RawCardData.ParseData(reply))); break; } } }
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; } } }