private bool PeekCommand(ref CardBuffer inBuffer) { CardBuffer RESP; CardBuffer CTRL = new CardBuffer("84"); RESP = ReaderChannel.Control(CTRL); if ((RESP == null) || (RESP.Length <= 1) || (RESP.GetByte(0) != 0x00)) { Trace.WriteLine("Control(" + CTRL.AsString() + ") failed"); if (RESP == null) { Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString); } else { Trace.WriteLine("\tResp= " + RESP.AsString()); } return(false); } byte[] buffer = new byte[RESP.Length - 1]; for (int i = 0; i < RESP.Length - 1; i++) { buffer[i] = RESP.GetByte(i + 1); } inBuffer = new CardBuffer(buffer); return(true); }
private bool PokeResponse(CardBuffer outBuffer) { CardBuffer RESP; CardBuffer CTRL; byte[] buffer = new byte[outBuffer.Length + 1]; buffer[0] = 0x84; for (int i = 0; i < outBuffer.Length; i++) { buffer[i + 1] = outBuffer.GetByte(i); } CTRL = new CardBuffer(buffer); RESP = ReaderChannel.Control(CTRL); if ((RESP == null) || (RESP.Length < 1) || (RESP.GetByte(0) != 0x00)) { Trace.WriteLine("Control(" + CTRL.AsString() + ") failed"); if (RESP == null) { Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString); } else { Trace.WriteLine("\tResp= " + RESP.AsString()); } return(false); } return(true); }
public bool WaitEvent(ref byte evtcode, ref byte evtflags, ushort timeout_ms) { CardBuffer RESP; byte[] _ctrl = new byte[4]; _ctrl[0] = 0x83; _ctrl[1] = 0x00; _ctrl[2] = (byte)(timeout_ms / 0x0100); _ctrl[3] = (byte)(timeout_ms % 0x0100); CardBuffer CTRL = new CardBuffer(_ctrl); RESP = ReaderChannel.Control(CTRL); if ((RESP == null) || (RESP.Length < 3) || (RESP.GetByte(0) != 0x00)) { Trace.WriteLine("Control(" + CTRL.AsString() + ") failed"); if (RESP == null) { Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString); } else { Trace.WriteLine("\tResp= " + RESP.AsString()); } return(false); } evtcode = RESP.GetByte(1); evtflags = RESP.GetByte(2); return(true); }
public bool GetEvent(ref byte evtcode, ref byte evtflags) { if (ReaderChannel == null) { return(false); } CardBuffer RESP; CardBuffer CTRL = new CardBuffer("8300"); RESP = ReaderChannel.Control(CTRL); if ((RESP == null) || (RESP.Length < 3) || (RESP.GetByte(0) != 0x00)) { Trace.WriteLine("Control(" + CTRL.AsString() + ") failed"); if (RESP == null) { Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString); } else { Trace.WriteLine("\tResp= " + RESP.AsString()); } return(false); } evtcode = RESP.GetByte(1); evtflags = RESP.GetByte(2); return(true); }
private bool DriveBuzzer(bool active) { if (ReaderChannel == null) { return(false); } CardBuffer RESP; CardBuffer CTRL; if (active) { CTRL = new CardBuffer("581C0040"); } else { CTRL = new CardBuffer("581C0200"); } RESP = ReaderChannel.Control(CTRL); if ((RESP == null) || (RESP.Length < 1) || (RESP.GetByte(0) != 0x00)) { return(false); } return(true); }
private bool EmulStop() { if (ReaderChannel == null) { return(false); } if (trace) { Trace.WriteLine("Stopping NFC card emulation"); } CardBuffer RESP; CardBuffer CTRL_LED = new CardBuffer("581E"); CardBuffer CTRL_BUZ = new CardBuffer("581C"); CardBuffer CTRL_NFC = new CardBuffer("83100000"); RESP = ReaderChannel.Control(CTRL_NFC); if ((RESP == null) || (RESP.Length < 1) || ((RESP.GetByte(0) != 0x00) && (RESP.GetByte(0) != 0x1D))) { if (trace) { Trace.WriteLine("Control(" + CTRL_NFC.AsString() + ") failed"); if (RESP == null) { Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString); } else { Trace.WriteLine("\tResp= " + RESP.AsString()); } } return(false); } ReaderChannel.Control(CTRL_LED); ReaderChannel.Control(CTRL_BUZ); return(true); }
private bool EmulStart() { if (ReaderChannel == null) { return(false); } if (trace) { Trace.WriteLine("Starting NFC card emulation"); } CardBuffer RESP; CardBuffer CTRL = new CardBuffer("83100100"); RESP = ReaderChannel.Control(CTRL); if ((RESP == null) || (RESP.Length < 1) || (RESP.GetByte(0) != 0x00)) { if (trace) { Trace.WriteLine("Control(" + CTRL.AsString() + ") failed"); if (RESP == null) { Trace.WriteLine("\terr." + ReaderChannel.LastError + " : " + ReaderChannel.LastErrorAsString); } else { Trace.WriteLine("\tResp= " + RESP.AsString()); } } return(false); } if (debug) { Trace.WriteLine("="); } return(true); }