public byte[] NtagRead(byte startPage) { _data = Iso14443Part3PassThru(NTAG_READ, startPage); switch (_data.Length) { case 1: // NAK throw NakException.NtagNakException(_data[0]); case 16: // PACK return(_data); default: throw new SmartCardException("Response of unexpected length (" + _data.Length + ") returned"); } }
public byte[] NtagFastRead(byte startPage, byte endPage) { _data = Iso14443Part3PassThru(NTAG_FAST_READ, startPage, endPage); if (_data.Length == 4 * (endPage - startPage + 1)) { return(_data); } else if (_data.Length == 1) { throw NakException.NtagNakException(_data[0]); } else { throw new SmartCardException("Response of unexpected length (" + _data.Length + ") returned"); } }
public bool NtagPasswordAuth(byte[] password) { if (password.Length == 4) { _data = Iso14443Part3PassThru(NTAG_PWD_AUTH, password[0], password[1], password[2], password[3]); switch (_data.Length) { case 0: return(false); // Incorrect Password case 1: // NAK throw NakException.NtagNakException(_data[0]); case 2: // PACK return(true); default: throw new SmartCardException("Response of unexpected length (" + _data.Length + ") returned"); } } return(false); }
public bool NtagWrite(byte page, byte[] data) { if (data.Length == 4) { _data = Iso14443Part3PassThru(NTAG_WRITE, page, data[0], data[1], data[2], data[3]); switch (_data.Length) { case 1: // ACK or NAK if (_data[0] == NTAG_ACK) { return(true); } else { throw NakException.NtagNakException(_data[0]); } default: throw new SmartCardException("Response of unexpected length (" + _data.Length + ") returned"); } } throw new SmartCardException("Input data should be 4 bytes"); }
public string NtagGetVersion() { _data = Iso14443Part3PassThru(NTAG_GET_VERSION); switch (_data.Length) { case 1: // NAK throw NakException.NtagNakException(_data[0]); case 8: Debug.Assert(_data[0] == 0x00); // header Debug.Assert(_data[1] == 0x04); // NXP Semiconductors Debug.Assert(_data[2] == 0x04); // NTAG Debug.Assert(_data[3] == 0x02); // product subtype Debug.Assert(_data[4] == 0x01); // major version Debug.Assert(_data[5] == 0x00); // minor version Debug.Assert(_data[7] == 0x03); // protocol type switch (_data[6]) { case 0x0F: return("NTAG213"); case 0x11: return("NTAG215"); case 0x13: return("NTAG216"); default: return("NTAGXXX"); } default: throw new SmartCardException("Response of unexpected length (" + _data.Length + ") returned"); } }