public static void Main()
var ndef = "en11203931373354377F061E28000000000000002200FFE01E0DFEC800000000000000000E00050F0210021102123D13FE0E0E140001001015009C010101160000FFFF1700BA1800141907D01A00141B0028FFAA1ED81C051D012504B0266427012805330A340A350A6503E83202";
Console.WriteLine("NDEF: \t" + ndef);
var cleaned = cleanNdefRecord(ndef);
Console.WriteLine("CLEANED: \t" + cleaned);
var deviceAddress = retrieveDeviceAddress(ndef);
Console.WriteLine("ADDRESS: \t" + deviceAddress);
var version = retrieveVersion(ndef, out major, out minor);
Console.WriteLine("VERSION: \t" + version);
Console.WriteLine("MAJOR: \t" + major);
Console.WriteLine("MINOR: \t" + minor);
var isNdefUpdated = isNDEFUpdatedV14(ndef, out isV14OrGreater);
Console.WriteLine("IS V1.14+: \t" + isV14OrGreater);
Console.WriteLine("RECORD UPDATED: \t" + isNdefUpdated);
var ndef2 = "en11203931373354377F061E28000000000000002200FFE01E0DFEC800000000000000000E00050F0210021102123D13FE0E0E140001001015009C010101160000FFFF1700BA1800141907D01A00141B0028FFAA1ED81C051D012504B0266427012805330A340A350A6503E83203";
isNdefUpdated = IsNdefRecordUpdated(ndef, ndef2);
Console.WriteLine("RECORD UPDATED (2):\t" + isNdefUpdated);
var ndefv114 = "en112039313733773777071E2E020000000000152202FFE01A0DFEC8000000000000000037000E01E00F0F100F110F123E13140E0E140000138815009C010101160000FFFF1700BA1800141907D01A00141BFFF2FF961F101C051D012500002600270128053300340A350A6503E83609383C6600803209";
isNdefUpdated = isNDEFUpdatedV14(ndefv114, out isV14OrGreater);
Console.WriteLine("IS V1.14+: \t" + isV14OrGreater);
Console.WriteLine("RECORD UPDATED: \t" + isNdefUpdated);
public static string retrieveVersion(string ndefRecord, out int Major, out int Minor)
ndefRecord = cleanNdefRecord(ndefRecord);
String version = ndefRecord.Substring(22, 2);
var versionByte = HexStringToByteArray(version);
Major = (versionByte[0] >> 5);
Minor = (versionByte[0] & 31);
return Major + "." + Minor;
public static string cleanNdefRecord(string ndefRecord)
if (ndefRecord.Contains("en"))
ndefRecord = ndefRecord.Replace("\0", "").Split("en".ToCharArray(), StringSplitOptions.RemoveEmptyEntries)[0];
public static string retrieveDeviceAddress(string ndefRecord)
ndefRecord = cleanNdefRecord(ndefRecord);
return ndefRecord.Substring(4, 16);
public static byte[] HexStringToByteArray(string hex)
return Enumerable.Range(0, hex.Length).Where(x => x % 2 == 0).Select(x => Convert.ToByte(hex.Substring(x, 2), 16)).ToArray();
public static bool isNDEFUpdatedV14(string ndefRecord, out bool IsVersion114OrGreater)
IsVersion114OrGreater = false;
var ndefRecordClean = cleanNdefRecord(ndefRecord);
String version = retrieveVersion(ndefRecordClean, out versionMajor, out versionMinor);
if (versionMinor >= 14 || versionMajor >= 2)
IsVersion114OrGreater = true;
string firstTick = ndefRecordClean.Substring(ndefRecordClean.Length - 2, 2);
int first = HexStringToByteArray(firstTick)[0];
private static bool IsNdefRecordUpdated(string firstNdef, string secondNdef)
firstNdef = cleanNdefRecord(firstNdef);
secondNdef = cleanNdefRecord(secondNdef);
string firstTick = firstNdef.Substring(firstNdef.Length - 2, 2);
string secondTick = secondNdef.Substring(secondNdef.Length - 2, 2);
return firstTick != secondTick;