OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
ClientIdentification.cs
1using System;
2
3namespace OSDP.Net.Model;
4
9public readonly struct ClientIdentification
10{
15 public byte[] VendorCode { get; }
16
20 public uint SerialNumber { get; }
21
29 public ClientIdentification(byte[] vendorCode, uint serialNumber)
30 {
31 if (vendorCode == null)
32 throw new ArgumentNullException(nameof(vendorCode));
33 if (vendorCode.Length != 3)
34 throw new ArgumentException("Vendor code must be exactly 3 bytes", nameof(vendorCode));
35
36 VendorCode = vendorCode;
37 SerialNumber = serialNumber;
38 }
39
45 public byte[] ToBytes()
46 {
47 var result = new byte[8];
48
49 // Copy vendor code (3 bytes)
50 VendorCode.CopyTo(result, 0);
51
52 // Copy thy serial number as little-endian (4 bytes)
53 result[3] = (byte)(SerialNumber & 0xFF);
54 result[4] = (byte)((SerialNumber >> 8) & 0xFF);
55 result[5] = (byte)((SerialNumber >> 16) & 0xFF);
56 result[6] = (byte)((SerialNumber >> 24) & 0xFF);
57
58 // Byte 7 is padding (already 0)
59
60 return result;
61 }
62
66 public override string ToString()
67 {
68 return $"VendorCode: {BitConverter.ToString(VendorCode)}, SerialNumber: {SerialNumber}";
69 }
70}
byte[] ToBytes()
Converts the client identification to an 8-byte array for use in the secure channel protocol.
ClientIdentification(byte[] vendorCode, uint serialNumber)
Creates a new ClientIdentification instance.
byte[] VendorCode
Vendor code assigned by the Security Industry Association (SIA).
override string ToString()
Returns a string representation of the client identification.