OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
NoPayloadCommandData.cs
1using System;
2using System.Text;
5
7
11internal class NoPayloadCommandData : CommandData
12{
13 private readonly CommandType[] _validCommandTypes =
14 {
15 CommandType.Abort,
16 CommandType.InputStatus,
17 CommandType.LocalStatus,
18 CommandType.OutputStatus,
19 CommandType.Poll,
20 CommandType.ReaderStatus
21 };
22
23 public NoPayloadCommandData(CommandType commandType)
24 {
25 if (Array.IndexOf(_validCommandTypes, commandType) < 0)
26 {
27 throw new ArgumentException("Invalid command type for a sending a payload with no data.");
28 }
29
30 CommandType = commandType;
31 }
32
34 public override byte Code => (byte)CommandType;
35
37 public override CommandType CommandType { get; }
38
40 public override ReadOnlySpan<byte> SecurityControlBlock() => SecurityBlock.CommandMessageWithNoDataSecurity;
41
43 public override byte[] BuildData()
44 {
45 return Array.Empty<byte>();
46 }
47
49 public override string ToString()
50 {
51 var sb = new StringBuilder();
52 sb.AppendLine($"Command Type: {CommandType}");
53 sb.AppendLine($" Payload: (none)");
54 return sb.ToString();
55 }
56}
Base class representing a payload of a PD command message.
ReadOnlySpan< byte > SecurityControlBlock()
Retrieves the security control block for a specific command data type.
byte[] BuildData()
Converts the payload into a byte array to be sent over the wire.