Implementing an RFID Provider
After you have determined what your provider should do, you can implement and code your provider.
The base capabilities of an RFID provider are defined by an implementation of DeviceProvider, which controls the provider initialization, shutdown, and administration. DeviceProvider also acts as a factory for PhysicalDeviceProxy, which controls the connection and communication with the physical device.
PhysicalDeviceProxy abstracts an RFID device and is the essence of the Device Service Provider Interface (DSPI). The class does the following:
-
Defines the message and transport layer.
-
Contains the methods for messaging and connection management. For example, all commands for configuring device properties go through PhysicalDeviceProxy.
-
Provides the notification framework for the device to send asynchronous events to the host.
-
There is one send channel through which commands are sent to the device. There are two receive channels: one through which the response to commands is received from the device, and the other through which notifications are received from the device.
-
Allows a device to surface properties, metadata, and other features.
At a minimum, you must implement the following members and methods for an RFID provider:
-
DeviceProvider.Init, DeviceProvider.GetDevice, DeviceProvider.Shutdown, and DeviceProvider.NotificationEvent.
-
The static GetProviderMetadata method.
-
All members of PhysicalDeviceProxy.
-
Printers and writers must also implement a series of print events and commands. For more information, see Printing and Writing to a Device.
The following describes the basic process to implement an RFID device provider.
To implement an RFID device provider-
Initialize your provider instance with .Init.
-
Optionally, implement device discovery with StartDiscovery, StopDiscovery, or TriggerDiscovery.
-
Expose provider metadata with GetProviderMetadata.
-
Expose device information with GetDeviceCapabilities.
-
Pass information to the RFID service by using ProviderNotificationEvent.
-
After your provider is registered, respond to an attempt to connect to a specific device with SetupConnection and DeviceInformation.
-
Implement the capabilities specific to your device.
This includes discovering a device, communicating with an antenna, printing, passing tag events, and so on. This also includes extending the DSPI interface to include vendor-specific features.
-
While performing the tasks necessary to your provider, ensure that your provider practices efficient resource and memory management techniques.
-
When the service is finished communicating with a specific device, close the connection with a call to PhysicalDeviceProxy.Close and Dispose.
-
When finished with the service, clean up and dispose of the provider instance with IDisposable.Dispose and .Shutdown.
-
How to Initialize and Shut Down a Provider
-
How to Discover a Device
-
Managing an RFID Connection
-
How to Manage Memory in an RFID Provider
-
How to Name a Device
-
How to Log Information for a Provider
-
Managing Errors and Events in an RFID Provider
-
How to Communicate with a Source or Antenna
-
Exposing Device and Provider Information
-
Printing and Writing to a Device
-
Implementing Vendor Extensions
-
Best Practices for Provider Writers
-
Globalizing a Provider
-
How to Implement Provider Security