Skip to content

Commit 91ae07c

Browse files
authored
Merge pull request #196 from Z-bit-Systems-LLC/develop
v5.0.6 Beta Release
2 parents 5ef4fa8 + 320f228 commit 91ae07c

File tree

155 files changed

+7206
-2640
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

155 files changed

+7206
-2640
lines changed

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,3 +37,5 @@ _UpgradeReport_Files/
3737
# For those who use p4diff/p4merge, ignore .orig files that
3838
# those tools seem to leave behind
3939
*.orig
40+
41+
.claude

CLAUDE.md

Lines changed: 42 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,42 @@
1+
# CLAUDE.md
2+
3+
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
4+
5+
## Build Commands
6+
- Build project: `dotnet build`
7+
- Build with specific configuration: `dotnet build --configuration Release`
8+
9+
## Test Commands
10+
- Run all tests: `dotnet test`
11+
- Run a specific test: `dotnet test --filter "FullyQualifiedName=OSDP.Net.Tests.{TestClass}.{TestMethod}"`
12+
- Run tests with specific configuration: `dotnet test --configuration Release`
13+
14+
## Code Style Guidelines
15+
- Follow default ReSharper C# coding style conventions
16+
- Maintain abbreviations in uppercase (ACU, LED, OSDP, PIN, PIV, UID, SCBK)
17+
- Follow async/await patterns for asynchronous operations
18+
- Use dependency injection for testability
19+
- Follow Arrange-Act-Assert pattern in tests
20+
- Implement proper exception handling with descriptive messages
21+
- Avoid blocking event threads
22+
- Use interfaces for abstraction (e.g., IOsdpConnection)
23+
- New commands should follow the existing command/reply model pattern
24+
- Place commands in appropriate namespaces (Model/CommandData or Model/ReplyData)
25+
26+
## Project Structure
27+
- Core library in `/src/OSDP.Net`
28+
- Tests in `/src/OSDP.Net.Tests`
29+
- Console application in `/src/Console`
30+
- Sample applications in `/src/samples`
31+
32+
## OSDP Implementation
33+
- **Command Implementation Status**: See `/docs/supported_commands.md` for current implementation status of OSDP v2.2 commands and replies
34+
- **Device (PD) Implementation**: The `Device` class in `/src/OSDP.Net/Device.cs` provides the base implementation for OSDP Peripheral Devices
35+
- **Command Handlers**: All command handlers are virtual methods in the Device class that can be overridden by specific device implementations
36+
- **Connection Architecture**:
37+
- Use `TcpConnectionListener` + `TcpOsdpConnection` for PDs accepting ACU connections
38+
- Use `TcpServerOsdpConnection` for ACUs accepting device connections
39+
- Use `SerialPortConnectionListener` for serial-based PD implementations
40+
41+
## Domain-Specific Terms
42+
- Maintain consistent terminology for domain-specific terms like APDU, INCITS, OSDP, osdpcap, rmac, Wiegand

Directory.Build.props

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
<Project>
2+
<PropertyGroup>
3+
<!-- Version properties will be set by GitVersion -->
4+
<VersionPrefix>5.0.5</VersionPrefix>
5+
6+
<!-- Common properties for all projects -->
7+
<Authors>Jonathan Horvath</Authors>
8+
<Company>Z-bit Systems LLC</Company>
9+
<Copyright>Copyright © $(Company) $([System.DateTime]::Now.Year)</Copyright>
10+
<Product>OSDP.Net</Product>
11+
<PackageLicenseExpression>Apache-2.0</PackageLicenseExpression>
12+
<PackageProjectUrl>https://github.com/bytedreamer/OSDP.Net</PackageProjectUrl>
13+
<PackageTags>OSDP;access-control;security;card-reader;biometric;ACU;PD;protocol;serial;tcp;door-access;physical-security</PackageTags>
14+
<PackageReleaseNotes>See https://github.com/bytedreamer/OSDP.Net/releases for release notes.</PackageReleaseNotes>
15+
<RepositoryUrl>https://github.com/bytedreamer/OSDP.Net.git</RepositoryUrl>
16+
<RepositoryType>git</RepositoryType>
17+
<PublishRepositoryUrl>true</PublishRepositoryUrl>
18+
<EmbedUntrackedSources>true</EmbedUntrackedSources>
19+
20+
<!-- Enable source link for debugging -->
21+
<IncludeSymbols>true</IncludeSymbols>
22+
<SymbolPackageFormat>snupkg</SymbolPackageFormat>
23+
24+
<!-- CI build settings -->
25+
<ContinuousIntegrationBuild Condition="'$(TF_BUILD)' == 'true'">true</ContinuousIntegrationBuild>
26+
</PropertyGroup>
27+
28+
<ItemGroup>
29+
<PackageReference Include="Microsoft.SourceLink.GitHub" Version="8.0.0" PrivateAssets="All" />
30+
</ItemGroup>
31+
</Project>

README.md

Lines changed: 96 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,21 @@
1-
[![SWUbanner](https://raw.githubusercontent.com/vshymanskyy/StandWithUkraine/main/banner2-direct.svg)](https://github.com/vshymanskyy/StandWithUkraine/blob/main/docs/README.md)
2-
31
# OSDP.Net
42

53
[![Build Status](https://dev.azure.com/jonathanhorvath/OSDP.Net/_apis/build/status/bytedreamer.OSDP.Net?branchName=develop)](https://dev.azure.com/jonathanhorvath/OSDP.Net/_build/latest?definitionId=1&branchName=develop)
64
[![NuGet](https://img.shields.io/nuget/v/OSDP.Net.svg?style=flat)](https://www.nuget.org/packages/OSDP.Net/)
75

8-
OSDP.Net is a .NET framework implementation of the Open Supervised Device Protocol (OSDP).
6+
OSDP.Net is a .NET implementation of the Open Supervised Device Protocol (OSDP).
97
This protocol has been adopted by the Security Industry Association (SIA) to standardize access control hardware communication.
108
Further information can be found at [SIA OSDP Homepage](https://www.securityindustry.org/industry-standards/open-supervised-device-protocol/).
119

10+
## Prerequisites
11+
12+
OSDP.Net supports the following .NET implementations:
13+
- .NET Framework 4.6.2 and later
14+
- NET 5.0 and later
15+
1216
## Getting Started
1317

14-
The OSDP.Net library provides a Nuget package to quickly add OSDP capability to a .NET Framework or Core project.
18+
The OSDP.Net library provides a Nuget package to quickly add OSDP capability to a .NET project.
1519
You can install it using the NuGet Package Console window:
1620

1721
```shell
@@ -40,7 +44,7 @@ Once the connection has started, add Peripheral Devices (PD).
4044
panel.AddDevice(connectionId, address, useCrc, useSecureChannel, secureChannelKey);
4145
```
4246

43-
The following code will install a PD with an unique Secure Channel key. The OSDP standard requires that setting the secure key can only occur while communications are secure.
47+
The following code will install a PD with a unique Secure Channel key. The OSDP standard requires that setting the secure key can only occur while communications are secure.
4448

4549
```c#
4650
panel.AddDevice(connectionId, address, useCrc, useSecureChannel); // connect using default SC key
@@ -62,10 +66,94 @@ var returnReplyData = await panel.OutputControl(connectionId, address, new Outpu
6266
The reader number parameter found in some commands is used for devices with multiple readers attached. If the device has a single reader, a value of zero should be used.
6367
```c#
6468
byte defaultReaderNumber = 0;
65-
bool success = await ReaderBuzzerControl(connectionId, address,
69+
bool success = await panel.ReaderBuzzerControl(connectionId, address,
6670
new ReaderBuzzerControl(defaultReaderNumber, ToneCode.Default, 2, 2, repeatNumber))
6771
```
6872

73+
## Common Usage Examples
74+
75+
### Reading Card Data
76+
```c#
77+
// Register for card read events
78+
panel.CardRead += async (sender, eventArgs) =>
79+
{
80+
await Task.Run(() =>
81+
{
82+
Console.WriteLine($"Card read from device {eventArgs.Address}");
83+
if (eventArgs.CardData is RawCardData rawData)
84+
{
85+
Console.WriteLine($"Raw card data: {BitConverter.ToString(rawData.Data)}");
86+
}
87+
else if (eventArgs.CardData is FormattedCardData formattedData)
88+
{
89+
Console.WriteLine($"Formatted card data: {formattedData.CardNumber}");
90+
}
91+
});
92+
};
93+
```
94+
95+
### Handling Device Events
96+
```c#
97+
// Monitor device status changes
98+
panel.InputStatusReport += async (sender, eventArgs) =>
99+
{
100+
await Task.Run(() =>
101+
{
102+
Console.WriteLine($"Input status changed on device {eventArgs.Address}");
103+
foreach (var input in eventArgs.InputStatuses)
104+
{
105+
Console.WriteLine($"Input {input.Number}: {(input.Active ? "Active" : "Inactive")}");
106+
}
107+
});
108+
};
109+
110+
// Handle NAK responses
111+
panel.NakReplyReceived += async (sender, eventArgs) =>
112+
{
113+
await Task.Run(() =>
114+
{
115+
Console.WriteLine($"NAK received from device {eventArgs.Address}: {eventArgs.Nak.ErrorCode}");
116+
});
117+
};
118+
```
119+
120+
### Managing Multiple Devices
121+
```c#
122+
// Add multiple devices on the same connection
123+
var devices = new[] { 0, 1, 2, 3 }; // Device addresses
124+
foreach (var address in devices)
125+
{
126+
panel.AddDevice(connectionId, address, useCrc: true, useSecureChannel: true);
127+
}
128+
129+
// Send commands to all devices
130+
foreach (var address in devices)
131+
{
132+
await panel.ReaderLedControl(connectionId, address, new ReaderLedControls(new[]
133+
{
134+
new ReaderLedControl(0, 0, LedColor.Green, LedColor.Black,
135+
30, 30, PermanentControlCode.SetPermanentState)
136+
}));
137+
}
138+
```
139+
140+
### Error Handling
141+
```c#
142+
try
143+
{
144+
var deviceId = await panel.IdReport(connectionId, address);
145+
Console.WriteLine($"Device ID: {deviceId.VendorCode:X}-{deviceId.ModelNumber}-{deviceId.Version}");
146+
}
147+
catch (TimeoutException)
148+
{
149+
Console.WriteLine("Device communication timeout");
150+
}
151+
catch (Exception ex)
152+
{
153+
Console.WriteLine($"Error communicating with device: {ex.Message}");
154+
}
155+
```
156+
69157
## Custom Communication Implementations
70158

71159
OSDP.Net is able to plugin different methods of communications beyond what is included with the default package.
@@ -79,7 +167,7 @@ It simply requires the installation a new NuGet package. The code needs to be up
79167
## Test Console
80168

81169
There is compiled version of the test console application for all the major platforms available for download.
82-
It has all the required assemblies included to run as a self containsed executable.
170+
It has all the required assemblies included to run as a self-contained executable.
83171
The latest version of the package can be found at [https://www.z-bitco.com/downloads/OSDPTestConsole.zip](https://www.z-bitco.com/downloads/OSDPTestConsole.zip)
84172
85173
NOTE: First determine the COM port identifier of the 485 bus connected to the computer.
@@ -93,4 +181,4 @@ Be sure to save configuration before exiting.
93181
## Contributing
94182

95183
The current goal is to properly support all the commands and replies outlined the OSDP v2.2 standard.
96-
The document that outlines the specific of the standard can be found on the [SIA website](https://mysia.securityindustry.org/ProductCatalog/Product.aspx?ID=16773). Contact me through my consulting company [Z-bit System, LLC](https://z-bitco.com), if interested in further collaboration with the OSDP.Net library.
184+
The document that outlines the specific of the standard can be found on the [SIA website](https://mysia.securityindustry.org/ProductCatalog/Product.aspx?ID=16773). Contact me through my consulting company [Z-bit System, LLC](https://z-bitco.com) if you're interested in collaborating on the OSDP.Net library.

api-baseline.txt

Lines changed: 140 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,140 @@
1+
# OSDP.Net Public API Baseline
2+
# Generated: 2025-08-24 12:00:00
3+
# Configuration: Release
4+
#
5+
# Format: [TYPE] FullTypeName
6+
#
7+
8+
# Core Classes
9+
[CLASS] OSDP.Net.ControlPanel
10+
[CLASS] OSDP.Net.Device
11+
[CLASS] OSDP.Net.DeviceConfiguration
12+
[CLASS] OSDP.Net.DeviceComSetUpdatedEventArgs
13+
[CLASS] OSDP.Net.Packet
14+
15+
# Interfaces
16+
[INTERFACE] OSDP.Net.Connections.IOsdpConnection
17+
[INTERFACE] OSDP.Net.Connections.IOsdpConnectionListener
18+
[INTERFACE] OSDP.Net.Messages.SecureChannel.IMessageSecureChannel
19+
20+
# Connection Classes
21+
[CLASS] OSDP.Net.Connections.OsdpConnection
22+
[CLASS] OSDP.Net.Connections.OsdpConnectionListener
23+
[CLASS] OSDP.Net.Connections.SerialPortOsdpConnection
24+
[CLASS] OSDP.Net.Connections.SerialPortConnectionListener
25+
[CLASS] OSDP.Net.Connections.TcpClientOsdpConnection
26+
[CLASS] OSDP.Net.Connections.TcpServerOsdpConnection
27+
[CLASS] OSDP.Net.Connections.TcpConnectionListener
28+
29+
# Exception Classes
30+
[CLASS] OSDP.Net.OSDPNetException
31+
[CLASS] OSDP.Net.NackReplyException
32+
[CLASS] OSDP.Net.InvalidPayloadException
33+
[CLASS] OSDP.Net.SecureChannelRequired
34+
35+
# Panel Commands and Discovery
36+
[CLASS] OSDP.Net.PanelCommands.DeviceDiscover.DeviceDiscoveryException
37+
[CLASS] OSDP.Net.PanelCommands.DeviceDiscover.ControlPanelInUseException
38+
[CLASS] OSDP.Net.PanelCommands.DeviceDiscover.DiscoveryOptions
39+
[CLASS] OSDP.Net.PanelCommands.DeviceDiscover.DiscoveryResult
40+
41+
# Event Args Classes
42+
[CLASS] OSDP.Net.Bus.ConnectionStatusEventArgs
43+
[CLASS] OSDP.Net.ControlPanel.NakReplyEventArgs
44+
[CLASS] OSDP.Net.ControlPanel.ConnectionStatusEventArgs
45+
[CLASS] OSDP.Net.ControlPanel.LocalStatusReportReplyEventArgs
46+
[CLASS] OSDP.Net.ControlPanel.InputStatusReportReplyEventArgs
47+
[CLASS] OSDP.Net.ControlPanel.OutputStatusReportReplyEventArgs
48+
[CLASS] OSDP.Net.ControlPanel.ReaderStatusReportReplyEventArgs
49+
[CLASS] OSDP.Net.ControlPanel.RawCardDataReplyEventArgs
50+
[CLASS] OSDP.Net.ControlPanel.FormattedCardDataReplyEventArgs
51+
[CLASS] OSDP.Net.ControlPanel.ManufacturerSpecificReplyEventArgs
52+
[CLASS] OSDP.Net.ControlPanel.KeypadReplyEventArgs
53+
[CLASS] OSDP.Net.ControlPanel.FileTransferStatus
54+
[CLASS] OSDP.Net.ControlPanel.FileTransferException
55+
56+
# Messages and Secure Channel
57+
[CLASS] OSDP.Net.Messages.Message
58+
[CLASS] OSDP.Net.Messages.SecureChannel.MessageSecureChannel
59+
[CLASS] OSDP.Net.Messages.SecureChannel.ACUMessageSecureChannel
60+
[CLASS] OSDP.Net.Messages.SecureChannel.SecurityContext
61+
[CLASS] OSDP.Net.Messages.SecureChannel.SecurityBlock
62+
63+
# Base Model Classes
64+
[CLASS] OSDP.Net.Model.PayloadData
65+
[CLASS] OSDP.Net.Model.CommandData.CommandData
66+
67+
# Command Data Classes
68+
[CLASS] OSDP.Net.Model.CommandData.ACUReceiveSize
69+
[CLASS] OSDP.Net.Model.CommandData.BiometricReadData
70+
[CLASS] OSDP.Net.Model.CommandData.BiometricTemplateData
71+
[CLASS] OSDP.Net.Model.CommandData.CommunicationConfiguration
72+
[CLASS] OSDP.Net.Model.CommandData.EncryptionKeyConfiguration
73+
[CLASS] OSDP.Net.Model.CommandData.GetPIVData
74+
[CLASS] OSDP.Net.Model.CommandData.KeepReaderActive
75+
[CLASS] OSDP.Net.Model.CommandData.ManufacturerSpecific
76+
[CLASS] OSDP.Net.Model.CommandData.OutputControl
77+
[CLASS] OSDP.Net.Model.CommandData.OutputControls
78+
[CLASS] OSDP.Net.Model.CommandData.ReaderBuzzerControl
79+
[CLASS] OSDP.Net.Model.CommandData.ReaderLedControl
80+
[CLASS] OSDP.Net.Model.CommandData.ReaderLedControls
81+
[CLASS] OSDP.Net.Model.CommandData.ReaderTextOutput
82+
83+
# Reply Data Classes
84+
[CLASS] OSDP.Net.Model.ReplyData.Ack
85+
[CLASS] OSDP.Net.Model.ReplyData.BiometricMatchResult
86+
[CLASS] OSDP.Net.Model.ReplyData.BiometricReadResult
87+
[CLASS] OSDP.Net.Model.ReplyData.CommunicationConfiguration
88+
[CLASS] OSDP.Net.Model.ReplyData.DataFragmentResponse
89+
[CLASS] OSDP.Net.Model.ReplyData.DeviceCapabilities
90+
[CLASS] OSDP.Net.Model.ReplyData.DeviceCapability
91+
[CLASS] OSDP.Net.Model.ReplyData.MsgSizeDeviceCap
92+
[CLASS] OSDP.Net.Model.ReplyData.RcvBuffSizeDeviceCap
93+
[CLASS] OSDP.Net.Model.ReplyData.LargestCombMsgSizeDeviceCap
94+
[CLASS] OSDP.Net.Model.ReplyData.CommSecurityDeviceCap
95+
[CLASS] OSDP.Net.Model.ReplyData.DeviceIdentification
96+
[CLASS] OSDP.Net.Model.ReplyData.FileTransferStatus
97+
[CLASS] OSDP.Net.Model.ReplyData.FormattedCardData
98+
[CLASS] OSDP.Net.Model.ReplyData.InputStatus
99+
[CLASS] OSDP.Net.Model.ReplyData.KeypadData
100+
[CLASS] OSDP.Net.Model.ReplyData.LocalStatus
101+
[CLASS] OSDP.Net.Model.ReplyData.ManufacturerSpecific
102+
[CLASS] OSDP.Net.Model.ReplyData.Nak
103+
[CLASS] OSDP.Net.Model.ReplyData.OutputStatus
104+
[CLASS] OSDP.Net.Model.ReplyData.RawCardData
105+
[CLASS] OSDP.Net.Model.ReplyData.ReaderStatus
106+
[CLASS] OSDP.Net.Model.ReplyData.ReturnReplyData
107+
108+
# Utility Classes
109+
[CLASS] OSDP.Net.Utilities.BinaryExtensions
110+
[CLASS] OSDP.Net.Utilities.BinaryUtils
111+
[CLASS] OSDP.Net.Utilities.Pollyfill
112+
113+
# Tracing Classes
114+
[CLASS] OSDP.Net.Tracing.OSDPCapEntry
115+
[CLASS] OSDP.Net.Tracing.PacketDecoding
116+
117+
# Enums
118+
[ENUM] OSDP.Net.Messages.CommandType
119+
[ENUM] OSDP.Net.Messages.ReplyType
120+
[ENUM] OSDP.Net.Messages.MessageType
121+
[ENUM] OSDP.Net.Messages.SecureChannel.SecurityBlockType
122+
[ENUM] OSDP.Net.Model.CommandData.BiometricFormat
123+
[ENUM] OSDP.Net.Model.CommandData.BiometricType
124+
[ENUM] OSDP.Net.Model.CommandData.GetPIVData.ObjectId
125+
[ENUM] OSDP.Net.Model.CommandData.OutputControlCode
126+
[ENUM] OSDP.Net.Model.CommandData.ReaderBuzzerControl.ToneCode
127+
[ENUM] OSDP.Net.Model.CommandData.ReaderLedControl.TemporaryReaderControlCode
128+
[ENUM] OSDP.Net.Model.CommandData.ReaderLedControl.PermanentReaderControlCode
129+
[ENUM] OSDP.Net.Model.CommandData.ReaderLedControl.LedColor
130+
[ENUM] OSDP.Net.Model.CommandData.ReaderTextOutput.TextCommand
131+
[ENUM] OSDP.Net.Model.CommandData.SecureChannelConfiguration.KeyType
132+
[ENUM] OSDP.Net.Model.ReplyData.BiometricStatus
133+
[ENUM] OSDP.Net.Model.ReplyData.CapabilityFunction
134+
[ENUM] OSDP.Net.Model.ReplyData.FileTransferStatus.StatusDetail
135+
[ENUM] OSDP.Net.Model.ReplyData.FormattedCardData.ReadDirection
136+
[ENUM] OSDP.Net.Model.ReplyData.Nak.ErrorCode
137+
[ENUM] OSDP.Net.Model.ReplyData.RawCardData.FormatCode
138+
[ENUM] OSDP.Net.Model.ReplyData.ReaderTamperStatus
139+
[ENUM] OSDP.Net.PanelCommands.DeviceDiscover.DiscoveryStatus
140+
[ENUM] OSDP.Net.Tracing.TraceDirection

0 commit comments

Comments
 (0)