public Iso7816.ApduResponse SignalACR(string readerName, ACRReaderControl ctrl) { byte ledStateCtrl = 0; if (ctrl.finalRed) { ledStateCtrl |= 1 << 0; } if (ctrl.finalGreen) { ledStateCtrl |= 1 << 1; } if (ctrl.redMask) { ledStateCtrl |= 1 << 2; } if (ctrl.greenMask) { ledStateCtrl |= 1 << 3; } if (ctrl.initRedBlink) { ledStateCtrl |= 1 << 4; } if (ctrl.initGreenBlink) { ledStateCtrl |= 1 << 5; } if (ctrl.redBlinkMask) { ledStateCtrl |= 1 << 6; } if (ctrl.greenBlinkMask) { ledStateCtrl |= 1 << 7; } byte[] ctrlData = new byte[] { ctrl.t1Duration, ctrl.t2Duration, ctrl.reps, ctrl.buzzer }; blockCardEvents += 1; try { using (ISCardContext ctx = contextFactory.Establish(SCardScope.System)) using (ICardReader reader = ctx.ConnectReader(readerName, SCardShareMode.Direct, SCardProtocol.Unset)) { var apdu = new Iso7816.ApduCommand(0xFF, 0x00, 0x40, ledStateCtrl, ctrlData, null); return(reader.Control(apdu)); } } finally { new Thread(() => { Thread.Sleep(((ctrl.t1Duration * 100) + (ctrl.t2Duration * 100)) * ctrl.reps); blockCardEvents -= 1; }).Start(); } // For all I'm aware, this always returns a failure APDU, but the reader does perform the specified action. }
public void SignalSuccess(string readerName) { ACRReaderControl ctrl = new ACRReaderControl { finalRed = true, initGreenBlink = true, greenBlinkMask = true, redMask = true, greenMask = true, t1Duration = 4, t2Duration = 4, reps = 5 }; SignalACR(readerName, ctrl); }
public void SignalFailure(string readerName) { ACRReaderControl ctrl = new ACRReaderControl { finalRed = true, initRedBlink = true, redBlinkMask = true, redMask = true, greenMask = true, t1Duration = 6, t2Duration = 4, reps = 3, buzzer = 1 }; SignalACR(readerName, ctrl); }