-
Notifications
You must be signed in to change notification settings - Fork 3
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Writing Data to CardChannelIso7816 #1
Comments
Hi. I'll try to give you some information. First, you must make sure that your NFC card is 7816-4 compliant. That means that it supports not only native NFC commands but also ISO/IEC 7816 APDU (Command & Response). That will allow you to use the CardChannelIso7816 channel to send CRP (Command Response Pair). Then you can use the example given in the var command = new CommandAPDU(0x90, 0xBD, 0x00, 0x00, new byte[] {}, 0x00) You may also extend the CommandAPDU to get easier to use commands, like this example for a Myfare EV1 card: public class ReadDataCommand : CommandAPDU
{
public ReadDataCommand(byte fileId, int offset, int length) : base(0x90, 0xBD, 0x00, 0x00, 0x00)
{
Udc = fileId.ToByteArray()
.Concat(offset.ToBytes(3).Reverse())
.Concat(length.ToBytes(3).Reverse())
.ToArray();
}
} then use it like this: var readDataCommand = new ReadDataCommand(1, 0, 31);
var crp = new CommandResponsePair(command);
if (crp.ErrorCode != ErrorCode.Success)
{
Console.WriteLine($"Something went wrong: {crp.ErrorCode}");
return;
}
// do whatever you want with crp.RApdu.Udr If you're looking for the supported commands list, you should have a look at this NFC Forum specification page 31 that defines the If your card is not 7816-4 then you may try to use the raw access to the card. Note that not all contactless readers support the raw mode. You won't be able to use the var rawChannel = new CardChannel(context, context.Readers.Last());
rawchannel.Connect(ShareMode.Exclusive, Protocol.Raw); You would then define a RawCommand class (for example the one defined in this gist) and build your commands. Hope it helps. |
No news is good news. Closing this issue :). |
Hey, would it be possible to receive some examples on how to write Data to a CardChannelIso7816?
So which Commands to use and what parameters to pass in?
I would just like to write some basic stirngs and afterwards read them from the NFC Tag.
For a non expert in NFC Communication trying to read the little Documentation on the Classes without some examples is really difficult.
Thank you very much in advance.
KingdomHeards3.
The text was updated successfully, but these errors were encountered: