|
OSDP.Net 5.3.0-beta.3
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
|
OSDP.Net is a .NET implementation of the Open Supervised Device Protocol (OSDP), the SIA standard for communication between access control panels and the readers and other peripheral devices (PDs) connected to them. The library can act as either side of the bus: a control panel (ACU) or a peripheral device.
It targets .NET 8 and later and .NET Framework 4.6.2 and later. Install it from NuGet:
| You are building | Start with | Then look at |
|---|---|---|
| A control panel (ACU) | OSDP.Net.ControlPanel | Its command methods and ...Received events |
| A peripheral device (PD) | OSDP.Net.Device and OSDP.Net.DeviceConfiguration | The Handle... methods to override |
| A connection | OSDP.Net.Connections.SerialPortOsdpConnection, OSDP.Net.Connections.TcpClientOsdpConnection, OSDP.Net.Connections.TcpServerOsdpConnection | OSDP.Net.Connections.IOsdpConnection to write your own |
| A PD listener | OSDP.Net.Connections.SerialPortConnectionListener, OSDP.Net.Connections.TcpConnectionListener | OSDP.Net.Connections.IOsdpConnectionListener |
Command payloads live in the OSDP.Net.Model.CommandData namespace and reply payloads in OSDP.Net.Model.ReplyData.
Register event handlers before starting the connection, and keep them short: they run on the thread that polls the bus.
Derive from OSDP.Net.Device and override the handlers for the commands your device supports. Commands without an override are answered with an osdp_NAK.
Card reads, keypad entries and other unsolicited replies are queued with OSDP.Net.Device.EnqueuePollReply and sent on the next poll.
The library runs the Secure Channel handshake itself. On the ACU, pass useSecureChannel: true (and a secureChannelKey, or the default installation key is used) to OSDP.Net.ControlPanel.AddDevice, then watch IsSecureChannelEstablished on OSDP.Net.ControlPanel.ConnectionStatusChanged. To give a PD its own key, call OSDP.Net.ControlPanel.EncryptionKeySet while the channel is secure. On the PD, set OSDP.Net.DeviceConfiguration.RequireSecurity and OSDP.Net.DeviceConfiguration.SecurityKey.
Command methods are awaitable. When the PD rejects a command with osdp_NAK, the task fails with OSDP.Net.NackReplyException, whose Reply holds the error code. A PD that doesn't answer within 8 seconds fails the task with a TimeoutException. Every NAK is also raised as OSDP.Net.ControlPanel.NakReplyReceived.