OSDP.Net 5.2.1
A .NET library for implementing the Open Supervised Device Protocol (OSDP)
Loading...
Searching...
No Matches
OSDP.Net.Device Class Reference

Represents a Peripheral Device (PD) that communicates over the OSDP protocol. More...

Inheritance diagram for OSDP.Net.Device:

Classes

class  DeviceComSetUpdatedEventArgs
 Event arguments for DeviceComSetUpdated event, which is raised whenever ACU requests the device to update its address and/or baud rate. More...

Public Member Functions

 Device (DeviceConfiguration config, ILoggerFactory loggerFactory=null)
 Represents a Peripheral Device (PD) that communicates over the OSDP protocol.
void Dispose ()
async Task StartListening (IOsdpConnectionListener connectionListener)
 Starts listening for commands from the ACU through the specified connection listener.
async Task StopListening ()
 Stops listening for OSDP messages on the device.
void EnqueuePollReply (PayloadData reply)
 Enqueues a reply into the pending poll reply queue.

Protected Member Functions

virtual void Dispose (bool disposing)
 Disposes the Device instance.
virtual PayloadData HandleIdReport ()
 Handles the ID Report Request command received from the OSDP device.
virtual PayloadData HandleExtendedIdReport ()
 Handles the Extended ID Report Request command received from the OSDP device.
virtual PayloadData HandleTextOutput (ReaderTextOutput commandPayload)
 Handles the text output command received from the OSDP device.
virtual PayloadData HandleBuzzerControl (ReaderBuzzerControl commandPayload)
 Handles the reader buzzer control command received from the OSDP device.
virtual PayloadData HandleOutputControl (OutputControls commandPayload)
 Handles the output controls command received from the OSDP device.
virtual PayloadData HandleDeviceCapabilities ()
 Handles the device capabilities request command received from the OSDP device.
virtual PayloadData HandlePivData (GetPIVData commandPayload)
 Handles the get PIV data command received from the OSDP device.
virtual PayloadData HandleManufacturerCommand (ManufacturerSpecific commandPayload)
 Handles the manufacturer-specific command received from the OSDP device.
virtual PayloadData HandleExtendedWrite (ExtendedWrite commandPayload)
 Handles the extended write (transparent mode) command received from the ACU.
virtual PayloadData HandleKeepActive (KeepReaderActive commandPayload)
 Handles the keep active command received from the OSDP device.
virtual PayloadData HandleAbortRequest ()
 Handles the abort request command received from the OSDP device.
virtual PayloadData HandleFileTransfer (FileTransferFragment commandPayload)
 Handles the file transfer command received from the OSDP device.
virtual PayloadData HandleMaxReplySize (ACUReceiveSize commandPayload)
 Handles the maximum ACU receive size command received from the OSDP device.
virtual PayloadData HandleKeySettings (EncryptionKeyConfiguration commandPayload)
 If deriving PD class is intending to support secure connections, it MUST override this method to provide its own means of persisting a newly set security key which was sent by the ACU.
virtual PayloadData HandleBiometricMatch (BiometricTemplateData commandPayload)
 Handles the biometric match command received from the OSDP device.
virtual PayloadData HandleBiometricRead (BiometricReadData commandPayload)
 Handles the biometric read command received from the OSDP device.
virtual PayloadData HandleCommunicationSet (CommunicationConfiguration commandPayload)
 If deriving PD class is intending to support updating the communication settings, it MUST override this method to provide its own means of persisting a new baud rate and address which was sent by the ACU.
virtual PayloadData HandleReaderLEDControl (ReaderLedControls commandPayload)
 Handles the reader LED controls command received from the OSDP device.
virtual PayloadData HandleReaderStatusReport ()
 Handles the reader status command received from the OSDP device.
virtual PayloadData HandleOutputStatusReport ()
 Handles the output status command received from the OSDP device.
virtual PayloadData HandleInputStatusReport ()
 Handles the input status command received from the OSDP device.
virtual PayloadData HandleLocalStatusReport ()
 Handles the reader local status command received from the OSDP device.

Properties

bool IsConnected [get]
 Gets a value indicating whether the device is currently connected.

Events

EventHandler< DeviceComSetUpdatedEventArgs > DeviceComSetUpdated
 Gets raised whenever osdp_ComSet command is successfully processed, and there is a change in either device address or baud rate.

Detailed Description

Represents a Peripheral Device (PD) that communicates over the OSDP protocol.

Definition at line 21 of file Device.cs.

Constructor & Destructor Documentation

◆ Device()

OSDP.Net.Device.Device ( DeviceConfiguration config,
ILoggerFactory loggerFactory = null )
inline

Represents a Peripheral Device (PD) that communicates over the OSDP protocol.

Definition at line 36 of file Device.cs.

References Device().

Referenced by Device().

Member Function Documentation

◆ Dispose() [1/2]

void OSDP.Net.Device.Dispose ( )
inline

Definition at line 44 of file Device.cs.

References Dispose().

Referenced by Dispose().

◆ Dispose() [2/2]

virtual void OSDP.Net.Device.Dispose ( bool disposing)
inlineprotectedvirtual

Disposes the Device instance.

This method is responsible for releasing any resources used by the Device instance.

Definition at line 78 of file Device.cs.

References StopListening().

◆ EnqueuePollReply()

void OSDP.Net.Device.EnqueuePollReply ( PayloadData reply)

Enqueues a reply into the pending poll reply queue.

Parameters
replyThe reply to enqueue.

References OSDP.Net.Messages.Abort, OSDP.Net.Messages.BioMatch, OSDP.Net.Messages.BioRead, OSDP.Net.Messages.BuzzerControl, OSDP.Net.Messages.CommunicationSet, OSDP.Net.Messages.DeviceCapabilities, OSDP.Net.Messages.ExtendedWrite, OSDP.Net.Messages.FileTransfer, HandleAbortRequest(), HandleBiometricMatch(), HandleBiometricRead(), HandleBuzzerControl(), HandleDeviceCapabilities(), HandleExtendedWrite(), HandleFileTransfer(), HandleInputStatusReport(), HandleKeepActive(), HandleLocalStatusReport(), HandleManufacturerCommand(), HandleMaxReplySize(), HandleOutputControl(), HandleOutputStatusReport(), HandlePivData(), HandleReaderLEDControl(), HandleReaderStatusReport(), HandleTextOutput(), OSDP.Net.Messages.IdReport, OSDP.Net.Messages.InputStatus, OSDP.Net.Messages.IncomingMessage.IsDataCorrect, OSDP.Net.Messages.KeepActive, OSDP.Net.Messages.KeySet, OSDP.Net.Messages.LEDControl, OSDP.Net.Messages.LocalStatus, OSDP.Net.Messages.ManufacturerSpecific, OSDP.Net.Messages.MaxReplySize, OSDP.Net.Messages.OutputControl, OSDP.Net.Messages.OutputStatus, OSDP.Net.Model.CommandData.ACUReceiveSize.ParseData(), OSDP.Net.Model.CommandData.BiometricReadData.ParseData(), OSDP.Net.Model.CommandData.BiometricTemplateData.ParseData(), OSDP.Net.Model.CommandData.CommunicationConfiguration.ParseData(), OSDP.Net.Model.CommandData.EncryptionKeyConfiguration.ParseData(), OSDP.Net.Model.CommandData.ExtendedWrite.ParseData(), OSDP.Net.Model.CommandData.FileTransferFragment.ParseData(), OSDP.Net.Model.CommandData.GetPIVData.ParseData(), OSDP.Net.Model.CommandData.KeepReaderActive.ParseData(), OSDP.Net.Model.CommandData.ManufacturerSpecific.ParseData(), OSDP.Net.Model.CommandData.OutputControls.ParseData(), OSDP.Net.Model.CommandData.ReaderBuzzerControl.ParseData(), OSDP.Net.Model.CommandData.ReaderLedControls.ParseData(), OSDP.Net.Model.CommandData.ReaderTextOutput.ParseData(), OSDP.Net.Messages.IncomingMessage.Payload, OSDP.Net.Messages.PivData, OSDP.Net.Messages.Poll, OSDP.Net.Messages.ReaderStatus, OSDP.Net.Messages.TextOutput, and OSDP.Net.Messages.IncomingMessage.Type.

◆ HandleAbortRequest()

virtual PayloadData OSDP.Net.Device.HandleAbortRequest ( )
inlineprotectedvirtual

Handles the abort request command received from the OSDP device.

Returns
A payload data response acknowledging the abort request.

Definition at line 372 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleBiometricMatch()

virtual PayloadData OSDP.Net.Device.HandleBiometricMatch ( BiometricTemplateData commandPayload)
inlineprotectedvirtual

Handles the biometric match command received from the OSDP device.

Parameters
commandPayloadThe biometric match command payload.
Returns
A payload data response containing the biometric match result.

Definition at line 442 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleBiometricRead()

virtual PayloadData OSDP.Net.Device.HandleBiometricRead ( BiometricReadData commandPayload)
inlineprotectedvirtual

Handles the biometric read command received from the OSDP device.

Parameters
commandPayloadThe biometric read command payload.
Returns
A payload data response containing the biometric read result.

Definition at line 452 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleBuzzerControl()

virtual PayloadData OSDP.Net.Device.HandleBuzzerControl ( ReaderBuzzerControl commandPayload)
inlineprotectedvirtual

Handles the reader buzzer control command received from the OSDP device.

Parameters
commandPayloadThe incoming reader buzzer control command payload.
Returns
A payload data response indicating the result of the buzzer control operation.

Definition at line 295 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleCommunicationSet()

virtual PayloadData OSDP.Net.Device.HandleCommunicationSet ( CommunicationConfiguration commandPayload)
inlineprotectedvirtual

If deriving PD class is intending to support updating the communication settings, it MUST override this method to provide its own means of persisting a new baud rate and address which was sent by the ACU.

NOTE: The consumer will need to listen to the DeviceComSetUpdated event. It allows it to reinitialize the connection after successfully sending the reply.

Parameters
commandPayloadThe requested communication settings command payload.
Returns
PdCommunicationsConfigurationReport - if updated communication settings are successfully accepted. Populate the data with the new values. Nak - if the communication settings are rejected

Definition at line 512 of file Device.cs.

◆ HandleDeviceCapabilities()

virtual PayloadData OSDP.Net.Device.HandleDeviceCapabilities ( )
inlineprotectedvirtual

Handles the device capabilities request command received from the OSDP device.

Returns
A payload data response containing the device capabilities. Override this method to provide actual device capabilities.

Definition at line 314 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleExtendedIdReport()

virtual PayloadData OSDP.Net.Device.HandleExtendedIdReport ( )
inlineprotectedvirtual

Handles the Extended ID Report Request command received from the OSDP device.

Returns
A payload data response containing extended device identification. Override this method to provide extended identification information.

This method is called when an osdp_ID command is received with data byte 0x01. The response should be an ExtendedDeviceIdentification containing TLV-encoded device information.

Definition at line 275 of file Device.cs.

◆ HandleExtendedWrite()

virtual PayloadData OSDP.Net.Device.HandleExtendedWrite ( ExtendedWrite commandPayload)
inlineprotectedvirtual

Handles the extended write (transparent mode) command received from the ACU.

Parameters
commandPayloadThe incoming extended write command payload.
Returns
A payload data response. Typically an ExtendedRead reply, an Ack, or a Nak.

Transparent mode tunnels ISO 7816-4 smart-card APDUs through a PD reader over the OSDP link. The default implementation NAKs with UnknownCommandCode; PDs that support transparent mode should override and return an ExtendedRead payload. To push an unsolicited XRD (e.g., card-present notification) call EnqueuePollReply with an ExtendedRead instance.

Definition at line 353 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleFileTransfer()

virtual PayloadData OSDP.Net.Device.HandleFileTransfer ( FileTransferFragment commandPayload)
inlineprotectedvirtual

Handles the file transfer command received from the OSDP device.

Parameters
commandPayloadThe incoming file transfer fragment command message.
Returns
A payload data response indicating the result of accepting the fragment. Override this method to receive files from the ACU; the spec permits only a FileTransferStatus or a Nak in reply. FileTransferReceiver implements the reassembly and status reporting that a conforming reply requires.

The base implementation NAKs, declaring that this PD accepts no file transfers. See OSDP v2.2.2 subclause 6.26.

Definition at line 391 of file Device.cs.

References OSDP.Net.Model.CommandData.FileTransferFragment.ToString().

Referenced by EnqueuePollReply().

◆ HandleIdReport()

virtual PayloadData OSDP.Net.Device.HandleIdReport ( )
inlineprotectedvirtual

Handles the ID Report Request command received from the OSDP device.

Returns
A payload data response to the ID report request. Override this method to provide device identification information.

Definition at line 262 of file Device.cs.

◆ HandleInputStatusReport()

virtual PayloadData OSDP.Net.Device.HandleInputStatusReport ( )
inlineprotectedvirtual

Handles the input status command received from the OSDP device.

Returns
A payload data response containing the current input status information.

Definition at line 549 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleKeepActive()

virtual PayloadData OSDP.Net.Device.HandleKeepActive ( KeepReaderActive commandPayload)
inlineprotectedvirtual

Handles the keep active command received from the OSDP device.

Parameters
commandPayloadThe incoming keep active command payload.
Returns
A payload data response acknowledging the keep active command.

Definition at line 363 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleKeySettings()

virtual PayloadData OSDP.Net.Device.HandleKeySettings ( EncryptionKeyConfiguration commandPayload)
inlineprotectedvirtual

If deriving PD class is intending to support secure connections, it MUST override this method to provide its own means of persisting a newly set security key which was sent by the ACU.

The base Device class will automatically pick up the new key for future connections if this function returns a successful Ack response. NOTE: Any existing connections will continue to use the previous key. It is up to the ACU to drop a connection and reconnect if it wishes to do so

Parameters
commandPayloadThe key settings command payload.
Returns
Ack - if the new key was successfully accepted Nak - if the new key was rejected

Definition at line 432 of file Device.cs.

◆ HandleLocalStatusReport()

virtual PayloadData OSDP.Net.Device.HandleLocalStatusReport ( )
inlineprotectedvirtual

Handles the reader local status command received from the OSDP device.

Returns
A payload data response containing the current local status information.

Definition at line 558 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleManufacturerCommand()

virtual PayloadData OSDP.Net.Device.HandleManufacturerCommand ( ManufacturerSpecific commandPayload)
inlineprotectedvirtual

Handles the manufacturer-specific command received from the OSDP device.

Parameters
commandPayloadThe incoming manufacturer-specific command payload.
Returns
A payload data response for the manufacturer-specific command.

Definition at line 334 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleMaxReplySize()

virtual PayloadData OSDP.Net.Device.HandleMaxReplySize ( ACUReceiveSize commandPayload)
inlineprotectedvirtual

Handles the maximum ACU receive size command received from the OSDP device.

Parameters
commandPayloadThe ACU maximum receive size command payload.
Returns
A payload data response acknowledging the maximum received size setting.

Definition at line 402 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleOutputControl()

virtual PayloadData OSDP.Net.Device.HandleOutputControl ( OutputControls commandPayload)
inlineprotectedvirtual

Handles the output controls command received from the OSDP device.

Parameters
commandPayloadThe incoming output controls a command payload.
Returns
A payload data response indicating the result of the output control operation.

Definition at line 305 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleOutputStatusReport()

virtual PayloadData OSDP.Net.Device.HandleOutputStatusReport ( )
inlineprotectedvirtual

Handles the output status command received from the OSDP device.

Returns
A payload data response containing the current output status information.

Definition at line 540 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandlePivData()

virtual PayloadData OSDP.Net.Device.HandlePivData ( GetPIVData commandPayload)
inlineprotectedvirtual

Handles the get PIV data command received from the OSDP device.

Parameters
commandPayloadThe incoming get PIV data command payload.
Returns
A payload data response containing the requested PIV data or appropriate error response.

Definition at line 324 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleReaderLEDControl()

virtual PayloadData OSDP.Net.Device.HandleReaderLEDControl ( ReaderLedControls commandPayload)
inlineprotectedvirtual

Handles the reader LED controls command received from the OSDP device.

Parameters
commandPayloadThe reader LED controls a command payload.
Returns
A payload data response indicating the result of the LED control operation.

Definition at line 522 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleReaderStatusReport()

virtual PayloadData OSDP.Net.Device.HandleReaderStatusReport ( )
inlineprotectedvirtual

Handles the reader status command received from the OSDP device.

Returns
A payload data response containing the current reader status information.

Definition at line 531 of file Device.cs.

Referenced by EnqueuePollReply().

◆ HandleTextOutput()

virtual PayloadData OSDP.Net.Device.HandleTextOutput ( ReaderTextOutput commandPayload)
inlineprotectedvirtual

Handles the text output command received from the OSDP device.

Parameters
commandPayloadThe incoming reader text output command payload.
Returns
A payload data response indicating the result of the text output operation.

Definition at line 285 of file Device.cs.

Referenced by EnqueuePollReply().

◆ StartListening()

async Task OSDP.Net.Device.StartListening ( IOsdpConnectionListener connectionListener)
inline

Starts listening for commands from the ACU through the specified connection listener.

Parameters
connectionListenerThe connection listener used to accept incoming connections from ACUs.

Definition at line 90 of file Device.cs.

◆ StopListening()

async Task OSDP.Net.Device.StopListening ( )
inline

Stops listening for OSDP messages on the device.

Definition at line 148 of file Device.cs.

Referenced by Dispose().

Property Documentation

◆ IsConnected

bool OSDP.Net.Device.IsConnected
get

Gets a value indicating whether the device is currently connected.

true if the device is connected; otherwise, false.

Definition at line 54 of file Device.cs.

Event Documentation

◆ DeviceComSetUpdated

EventHandler<DeviceComSetUpdatedEventArgs> OSDP.Net.Device.DeviceComSetUpdated

Gets raised whenever osdp_ComSet command is successfully processed, and there is a change in either device address or baud rate.

Because baud rate is configured on the OSDP connection/server that is passed down into the Device class, it is up to the consumer of the Device class (i.e., whatever code that creates that class in the first place) to properly handle this event and re-initialize the Device with the correct connection settings.

NOTE: In addition to this event, there's also HandleCommunicationSet which the deriving class MUST override if it is to support osdp_ComSet properly. The overriding allows the device to validate and accept/reject the command parameters which occurs prior to this event

Definition at line 70 of file Device.cs.


The documentation for this class was generated from the following file: