Exemplo n.º 1
0
        public static String readUID()
        {
            String output = NFCTool.exec("nfc-list.exe").Trim();
            Regex  regx   = new Regex("UID \\(\\S*\\): ((\\S\\S\\s\\s){4})", RegexOptions.IgnoreCase);

            if (regx.IsMatch(output))
            {
                return(regx.Match(output).Value.ToUpper().Replace(" ", "").Split(':')[1]);
            }
            return("");
        }
Exemplo n.º 2
0
 private void searchTimer_Tick(object sender, EventArgs e)
 {
     if (NFCTool.checkDevice())
     {
         this.searchTimer.Stop();
         this.label1.Enabled   = true;
         this.readUID.Enabled  = true;
         this.writeUID.Enabled = true;
         this.uid.Enabled      = true;
         this.log(NFCTool.getDeviceName());
         this.status.Text = "Ready";
     }
 }
Exemplo n.º 3
0
 private void writeUID_Click(object sender, EventArgs e)
 {
     if (NFCTool.checkUID(this.uid.Text))
     {
         this.status.Text      = "Writing UID.";
         this.uid.Enabled      = false;
         this.readUID.Enabled  = false;
         this.writeUID.Enabled = false;
         this.log("Write UID:" + this.uid.Text);
         this.log(NFCTool.writeUID(this.uid.Text));
         this.uid.Enabled      = true;
         this.readUID.Enabled  = true;
         this.writeUID.Enabled = true;
         this.status.Text      = "Ready";
     }
     else
     {
         MessageBox.Show("Not a valid UID.");
     }
 }
Exemplo n.º 4
0
        private void readUID_Click(object sender, EventArgs e)
        {
            this.status.Text      = "Reading UID.";
            this.uid.Enabled      = false;
            this.readUID.Enabled  = false;
            this.writeUID.Enabled = false;
            String origin_uid = NFCTool.readUID();

            if (origin_uid != "")
            {
                this.log("Get UID:" + origin_uid);
                this.uid.Text = origin_uid;
            }
            else
            {
                this.log("Unrecognized card.");
            }
            this.uid.Enabled      = true;
            this.readUID.Enabled  = true;
            this.writeUID.Enabled = true;
            this.status.Text      = "Ready";
        }
Exemplo n.º 5
0
 public static String writeUID(string uid)
 {
     return(NFCTool.exec("nfc-mfsetuid.exe", " -f " + uid).Trim());
 }
Exemplo n.º 6
0
 public static String getDeviceName()
 {
     return(NFCTool.exec("nfc-list.exe").Trim().Split('\n')[1].Replace("opened", "").Trim());
 }
Exemplo n.º 7
0
 public static bool checkDevice()
 {
     return(!NFCTool.exec("nfc-list.exe").Trim().Contains("No NFC device found."));
 }