Esempio n. 1
0
        private byte[] GetRandom(byte[] uid = null)
        {
            byte[] cmdIdentify = ISO15693.BuildCommand(ISO15693.Command.NXP_GET_RANDOM_NUMBER, uid, null);
            byte[] data        = SendCommand(cmdIdentify);

            if (data == null || data.Length != 5)
            {
                LogWindow.Log(LogWindow.eLogLevel.Debug, "[PM3] GetRandom: Failed (" + ((data == null) ? "no resp" : (data.Length + " bytes")) + ")");
                return(null);
            }

            byte[] rnd = new byte[2];
            Array.Copy(data, 1, rnd, 0, 2);

            return(rnd);
        }
Esempio n. 2
0
        private byte[] ReadMemory(int bank, int tries = 1)
        {
            for (int tried = 0; tried < tries; tried++)
            {
                byte[] cmdReadMem = ISO15693.BuildCommand(ISO15693.Command.READBLOCK, new[] { (byte)bank });
                byte[] data       = SendCommand(cmdReadMem);

                if (data == null || data.Length != 7)
                {
                    LogWindow.Log(LogWindow.eLogLevel.Debug, "[PM3] ReadMemory: Failed (" + ((data == null) ? "no resp" : (data.Length + " bytes")) + ")");
                    continue;
                }

                byte[] mem = new byte[4];
                Array.Copy(data, 1, mem, 0, 4);

                string str = BitConverter.ToString(mem.ToArray()).Replace("-", "");
                LogWindow.Log(LogWindow.eLogLevel.Debug, "[PM3] ReadMemory: ACK, returning " + str + "");
                return(mem);
            }
            return(null);
        }
Esempio n. 3
0
        private byte[] GetUID(int tries = 1)
        {
            for (int tried = 0; tried < tries; tried++)
            {
                byte[] cmdIdentify = ISO15693.BuildCommand(ISO15693.Command.INVENTORY, new byte[1]);
                byte[] data        = SendCommand(cmdIdentify);

                if (data == null || data.Length != 12)
                {
                    LogWindow.Log(LogWindow.eLogLevel.Debug, "[PM3] GetUID: Failed (" + ((data == null) ? "no resp" : (data.Length + " bytes")) + ")");
                    continue;
                }

                byte[] uidBytes = new byte[8];
                Array.Copy(data, 2, uidBytes, 0, 8);

                string uid = BitConverter.ToString(uidBytes.Reverse().ToArray()).Replace("-", "");
                LogWindow.Log(LogWindow.eLogLevel.Debug, "[PM3] GetUID: ACK, returning " + uid.Length + " byte");
                return(uidBytes);
            }
            return(null);
        }