Esempio n. 1
0
 private void RestoreReader()
 {
     EmulStop();
     if (ReaderChannel != null)
     {
         ReaderChannel.Disconnect();
         ReaderChannel = null;
     }
 }
Esempio n. 2
0
        public bool Control(CardBuffer cctrl, out CardBuffer rctrl)
        {
            rctrl = null;
            SCardChannel channel = new SCardChannel(this);

            if (!channel.ConnectDirect())
            {
                return(false);
            }
            bool rc = channel.Control(cctrl, out rctrl);

            channel.DisconnectLeave();
            return(rc);
        }
Esempio n. 3
0
        private bool PrepareReader()
        {
            if (ReaderChannel != null)
            {
                ReaderChannel.Disconnect();
                ReaderChannel = null;
            }

            if (ReaderName.Equals(""))
            {
                return(false);
            }

            ReaderChannel = new SCardChannel(ReaderName);

            ReaderChannel.ProtocolAsString = "DIRECT";

            if (!ReaderChannel.Connect())
            {
                if (trace)
                {
                    Trace.WriteLine("Failed to connect to the reader");
                    Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString);
                }
                ReaderChannel = null;
                return(false);
            }

            if (!EmulStart())
            {
                if (trace)
                {
                    Trace.WriteLine("Failed to enter NFC emulation mode");
                }
                EmulStop();
                ReaderChannel.Disconnect();
                ReaderChannel = null;
                return(false);
            }

            DriveLeds(false);
            DriveBuzzer(true);

            return(true);
        }
 public SCardMifareUltraLightC(SCardChannel card_channel)
 {
     hCard       = card_channel.hCard;
     _last_error = SCARD.MifUlC_AttachLibrary(hCard);
 }