OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
BiometricTemplateData.cs
1using System;
2using System.Collections.Generic;
5
7{
12 {
21 public BiometricTemplateData(byte readerNumber, BiometricType biometricType, BiometricFormat biometricFormatType,
22 byte qualityThreshold, byte[] templateData)
23 {
24 ReaderNumber = readerNumber;
25 BiometricType = biometricType;
26 BiometricFormatType = biometricFormatType;
27 QualityThreshold = qualityThreshold;
28 TemplateData = templateData;
29 }
30
34 public byte ReaderNumber { get; }
35
40
45
49 public byte QualityThreshold { get; }
50
54 public byte[] TemplateData { get; }
55
57 public override CommandType CommandType => CommandType.BioMatch;
58
60 public override byte Code => (byte)CommandType;
61
63 public override ReadOnlySpan<byte> SecurityControlBlock() => SecurityBlock.CommandMessageWithDataSecurity;
64
66 public override byte[] BuildData()
67 {
68 var data = new List<byte>
69 {
71 (byte)BiometricType,
74 };
75 data.AddRange(Message.ConvertShortToBytes((ushort)TemplateData.Length));
76 data.AddRange(TemplateData);
77 return data.ToArray();
78 }
79
83 public static BiometricTemplateData ParseData(ReadOnlySpan<byte> data)
84 {
85 short length = Message.ConvertBytesToShort(data.Slice(4, 2), true);
86
87 return new BiometricTemplateData(
88 data[0],
89 (BiometricType)data[1],
90 (BiometricFormat)data[2],
91 data[3],
92 data.Slice(6, length).ToArray());
93 }
94 }
95}
A base message class for sending or replying.
Definition Message.cs:12
Contains standard Security Control Block data that can be used when building messages.
static BiometricTemplateData ParseData(ReadOnlySpan< byte > data)
Parses the message payload bytes.
byte[] TemplateData
Gets the biometric template data.
BiometricType BiometricType
Gets the type/body part to scan.
BiometricTemplateData(byte readerNumber, BiometricType biometricType, BiometricFormat biometricFormatType, byte qualityThreshold, byte[] templateData)
Initializes a new instance of the BiometricTemplateData class.
BiometricFormat BiometricFormatType
Gets the format of the attached template.
byte ReaderNumber
Gets the reader number starting at 0.
override ReadOnlySpan< byte > SecurityControlBlock()
byte QualityThreshold
Gets the threshold required for accepting biometric match.
Base class representing a payload of a PD command message.
BiometricFormat
Format of data to be scanned.