public static NfcTagType4Desfire Read(SCardChannel channel) { NfcTagType4Desfire t = new NfcTagType4Desfire(channel); t.Read(); return(t); }
/**m* SpringCardNFC/NfcTag.Recognize * * SYNOPSIS * public static bool Recognize(SCardChannel cardchannel, out NfcTag tag, out string msg) * * DESCRIPTION * Determines if the card on the reader is a NFC Forum compliant tag * It first checks the ATR to determine if the card can be type 2 or * a type 4 and tries to recognize the content of the tag. * It creates either a NfcTagType2 or a NfcTagType4 and returns true if the tag is recognized. * It returns false if the card is not a NFC Forum tag * * SEE ALSO * NfcTagType2.RecognizeAtr * NfcTagType2.Recognize * NfcTagType2.Create * NfcTagType4.Recognize * NfcTagType4.Create * * **/ public static bool Recognize(SCardChannel cardchannel, out NfcTag tag, out string msg, out bool Desfire_formatable) { bool res = false; msg = ""; tag = null; Desfire_formatable = false; if (NfcTagType2.RecognizeAtr(cardchannel)) { Trace.WriteLine("Based on the ATR, this card is likely to be a NFC type 2 Tag"); if (NfcTagType2.Recognize(cardchannel)) { Trace.WriteLine("This card is actually a NFC type 2 Tag"); tag = NfcTagType2.Create(cardchannel); if (tag == null) { msg = "An error has occured while reading the Tag's content"; } res = true; } else { Trace.WriteLine("Based on its content, this card is not a NFC type 2 Tag, sorry"); msg = "From the ATR it may be a NFC type 2 Tag, but the content is invalid"; } } else if (NfcTagType4.Recognize(cardchannel)) { Trace.WriteLine("This card is a NFC type 4 Tag"); tag = NfcTagType4.Create(cardchannel); if (tag == null) { msg = "An error has occured while reading the Tag's content"; } res = true; } else #if (NFC_TAGS_DESFIRE) if (NfcTagType4Desfire.Recognize(cardchannel)) { msg = "A DESFire EV1 card has been detected.\nIt may be formatted into a type 4 Tag."; Desfire_formatable = true; res = false; } else #endif { msg = "Unrecognized or unsupported card"; tag = null; } return(res); }