/// <summary> /// Loads Athentication Keys into the system /// </summary> /// <param name="Key">A enumeration as A or B for if you want to match keys to memory(A is read key B is master)</param> /// <param name="KeyValue">The Value Key to use. Length must be six</param> /// <returns></returns> public ACR122U_ResposeErrorCodes LoadAthenticationKeys(ACR122U_Keys Key, byte[] KeyValue) { if (!Enum.IsDefined(typeof(ACR122U_Keys), Key)) { throw new Exception("Your Key Selection is not a valid one."); } return(LoadAthenticationKeys((ACR122U_KeyMemories)Key, KeyValue)); }
/// <summary> /// Uses prev loaded Athentication Keys to Athenticate /// </summary> /// <param name="Key">A enumeration as A or B</param> /// <param name="Key">A enumeration as A or B for if you want to match keys to memory(A is read key B is master)</param> /// <returns></returns> public ACR122U_ResposeErrorCodes Athentication(byte BlockToAthenticate, ACR122U_Keys Key, ACR122U_Keys KeyToUse) { if (!Enum.IsDefined(typeof(ACR122U_Keys), KeyToUse)) { throw new Exception("Your Key Selection for KeyToUse is not a valid one."); } if (!Enum.IsDefined(typeof(ACR122U_Keys), Key)) { throw new Exception("Your Key Selection for Key is not a valid one."); } LastACRResultCode = Athentication(BlockToAthenticate, Key, (ACR122U_KeyMemories)KeyToUse); return(LastACRResultCode); }
/*Load Key * Send * FF 86 00 00 05 01 00 00 60 01 * or * FF 86 00 00 05 01 00 [Block:00-FF] 6{000<KeyType:0=A,1=B>} [KeyNumber:00-01] * Returns * 90 00 * Note in a 4 block sector the last block is the key block */ /// <summary> /// Uses prev loaded Athentication Keys to Athenticate /// </summary> /// <param name="Key">A enumeration as A or B</param> /// <param name="KeyToUse">A enumeration as 1 or 2 for posible memory locations</param> /// <returns></returns> public ACR122U_ResposeErrorCodes Athentication(byte BlockToAthenticate, ACR122U_Keys Key, ACR122U_KeyMemories KeyToUse) { if (!Enum.IsDefined(typeof(ACR122U_KeyMemories), KeyToUse)) { throw new Exception("Your Key Load location is not a valid one."); } if (!Enum.IsDefined(typeof(ACR122U_Keys), Key)) { throw new Exception("Your Key Selection is not a valid one."); } byte[] Return; byte[] CommandAsBytes = new byte[10] { 0xFF, 0x86, 0x00, 0x00, 0x05, 0x01, 0x00, BlockToAthenticate, (byte)(0x60 | (byte)Key), (byte)KeyToUse }; TransmitData(CommandAsBytes, out Return); LastACRResultCode = RetrieveDataCodes(ref Return); return(LastACRResultCode); }