From 7fa2159d05910384ee72a8295a021343d7545a78 Mon Sep 17 00:00:00 2001 From: Eveldee Date: Mon, 30 Nov 2020 09:20:51 +0100 Subject: [PATCH] Add Comparison11 and TryComparison1N commands --- .../FingerprintSensor.cs | 39 +++++++++++++++++++ 1 file changed, 39 insertions(+) diff --git a/WaveshareUARTFingerprintSensor/FingerprintSensor.cs b/WaveshareUARTFingerprintSensor/FingerprintSensor.cs index 727ae5d..0aabb86 100644 --- a/WaveshareUARTFingerprintSensor/FingerprintSensor.cs +++ b/WaveshareUARTFingerprintSensor/FingerprintSensor.cs @@ -332,6 +332,45 @@ namespace WaveshareUARTFingerprintSensor return false; } + + /// + /// Read a fingerprint and check if it matches with the specified user + /// + /// A registered user ID + /// + public bool Comparison11(ushort userID) + { + (byte high, byte low) = Utils.Split(userID); + + if (TrySendAndReceive(CommandType.Comparison11, high, low, 0, out var response, 1000)) + { + return response.responseType == ResponseType.Success; + } + + return false; + } + + /// + /// Read a fingerprint and check if it match with any registered user + /// + /// The matched user info + /// + public bool TryComparison1N(out (ushort userID, UserPermission permission) userInfo) + { + if (TrySendAndReceive(CommandType.Comparison11, 0, 0, 0, out var response, 1000)) + { + if (response.responseType != ResponseType.NoUser && response.responseType != ResponseType.Timeout) + { + userInfo = (Utils.Merge(response.first, response.second), (UserPermission)response.responseType); + + return true; + } + } + + userInfo = default; + + return false; + } private void OnWake() { if (_wakePin.Read())