Giter Club home page Giter Club logo

osdp.net's Introduction

SWUbanner

OSDP.Net

Build Status NuGet

OSDP.Net is a .NET framework implementation of the Open Supervised Device Protocol (OSDP). This protocol has been adopted by the Security Industry Association (SIA) to standardize access control hardware communication. Further information can be found at SIA OSDP Homepage.

Getting Started

The OSDP.Net library provides a Nuget package to quickly add OSDP capablitity to a .NET Framework or Core project. You can install it using the NuGet Package Console window:

PM> Install-Package OSDP.Net

A control panel can be created and started with a few lines. Be sure to register events before start the connection.

var panel = new ControlPanel();
panel.ConnectionStatusChanged += (sender, eventArgs) =>
{
    // NOTE: Avoid blocking the thread so the control panel can continue polling
    Task.Run(async () =>
    {
        // Handle connection change event
    });
};
Guid connectionId = panel.StartConnection(new SerialPortOsdpConnection(portName, baudRate));

Once the connection has started, add Peripheral Devices (PD).

panel.AddDevice(connectionId, address, useCrc, useSecureChannel, secureChannelKey);

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.

panel.AddDevice(connectionId, address, useCrc, useSecureChannel); // connect using default SC key
bool successfulSet = await panel.EncryptionKeySet(connectionId, address, 
    new EncryptionKeyConfiguration(KeyType.SecureChannelBaseKey, uniqueKey));

The ControlPanel object can then be used to send command to the PD.

var returnReplyData = await panel.OutputControl(connectionId, address, new OutputControls(new[]
{
    new OutputControl(outputNumber, activate
        ? OutputControlCode.PermanentStateOnAbortTimedOperation
        : OutputControlCode.PermanentStateOffAbortTimedOperation, 0)
});

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.

byte defaultReaderNumber = 0;
bool success = await ReaderBuzzerControl(connectionId, address, 
    new ReaderBuzzerControl(defaultReaderNumber, ToneCode.Default, 2, 2, repeatNumber))

Custom Communication Implementations

OSDP.Net is able to plugin different methods of communications beyond what is included with the default package. It simply requires the installation a new NuGet package. The code needs to be updated by using it's implementation of the IOsdpConnection interface when starting a connection for the ControlPanel.

  • SerialPortStream
    • Author: Fredrik Hall
    • Links: GitHub Nuget
    • Notes: Requires compilation of native libraries for non-Windows platforms

Test Console

There is compiled version of the test console application for all the major platforms available for download. It has all the required assemblies included to run as a self containsed executable. The latest version of the package can be found at https://www.z-bitco.com/downloads/OSDPTestConsole.zip

NOTE: First determine the COM port identifier of the 485 bus connected to the computer. This will need to be entered when starting the connection. Be sure to save configuration before exiting.

Documentation

Contributing

The current goal is to properly support all the commands and replies outlined the OSDP v2.2 standard. The document that outlines the specific of the standard can be found on the SIA website. DM me on Twitter Follow NUnit if you are interesting in helping.

osdp.net's People

Contributors

bytedreamer avatar dxm007 avatar fattymatty195 avatar hallsbyra avatar ldholmgren avatar mikaelj avatar silverdark avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.