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(""); }
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"; } }
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."); } }
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"; }
public static String writeUID(string uid) { return(NFCTool.exec("nfc-mfsetuid.exe", " -f " + uid).Trim()); }
public static String getDeviceName() { return(NFCTool.exec("nfc-list.exe").Trim().Split('\n')[1].Replace("opened", "").Trim()); }
public static bool checkDevice() { return(!NFCTool.exec("nfc-list.exe").Trim().Contains("No NFC device found.")); }