Exemplo n.º 1
0
        /// <summary>
        /// Returns a card's UID.
        /// </summary>
        public ReceiveCardIdResult GetCardId(Card cardToRead)
        {
            if (cardToRead == null)
            {
                throw new ArgumentNullException("cardToRead");
            }

            var bytesToSend = new byte[5];

            bytesToSend[0] = 0xFF;             // Class
            bytesToSend[1] = 0xCA;             // INS
            bytesToSend[2] = 0x00;             // P1
            bytesToSend[3] = 0x00;             // P2
            bytesToSend[4] = 0x00;             // LE:Full Length

            ApduResponse response = SendAPDU(cardToRead, bytesToSend, 10);

            const int responseCodeLength = 2;
            var       responseLengthWithoutResponseCodes = response.ResponseLength - responseCodeLength;

            var receiveCardIdResult = new ReceiveCardIdResult(ReturnCodeManager.IsApduSuccessful(response));

            if (receiveCardIdResult.IsCompletelySuccessful)
            {
                //read UID bytes from apdu response
                receiveCardIdResult.Bytes = response.RecvBuff.Take(responseLengthWithoutResponseCodes).ToArray();
            }

            return(receiveCardIdResult);
        }
Exemplo n.º 2
0
        public ApduOperationResult SetBuzzerOutputForCardDetection(Card card, bool shouldBuzzWhenCardDetected)
        {
            var bytesToSend = new byte[5];

            bytesToSend[0] = 0xFF;
            bytesToSend[1] = 0x00;
            bytesToSend[2] = 0x52;
            bytesToSend[3] = shouldBuzzWhenCardDetected ? (byte)0xFF : (byte)0x00;
            bytesToSend[4] = 0x00;

            const int responseCodeLength = 2;

            ApduResponse response = SendAPDU(card, bytesToSend, responseCodeLength);

            return(ReturnCodeManager.IsApduSuccessful(response));
        }
Exemplo n.º 3
0
        public ApduOperationResult UpdateLedAndBuzzer(Card card, byte ledState, byte t1, byte t2, byte repetitionNumber, byte buzzer)
        {
            var bytesToSend = new byte[9];

            bytesToSend[0] = 0xFF;
            bytesToSend[1] = 0x00;
            bytesToSend[2] = 0x40;
            bytesToSend[3] = ledState;
            bytesToSend[4] = 0x04;
            bytesToSend[5] = t1;
            bytesToSend[6] = t2;
            bytesToSend[7] = repetitionNumber;
            bytesToSend[8] = buzzer;

            const int responseCodeLength = 2;

            ApduResponse response = SendAPDU(card, bytesToSend, responseCodeLength);

            return(ReturnCodeManager.IsApduSuccessful(response));
        }