Skip to content

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Repository files navigation

CSLibrary2026

CSL RFID Reader Library for .NET — supporting Bluetooth LE and TCP/IP communication with CSL RFID readers.

Supported Readers

Reader Connection
CS108 Bluetooth LE
CS468 Bluetooth LE
CS710S Bluetooth LE
CS203XL Bluetooth LE / TCP/IP
CS463 TCP/IP (Intel low level API, port 1515)
CS203X TCP/IP (Intel low level API, port 1515)
CS468 / CS468INT / CS468X / CS468XJ TCP/IP (Intel low level API, port 1515)

The reader type that is shown for a reader that has been found by the search is resolved by CSLibrary.Tools.RFIDReaderTypeMap. Every application of the reader family uses that map, so a reader is named the same way in every application.

Build flavours

Keep this matrix in sync with the ## Build & distribution matrix section in AGENTS.md.

NuGet package (Bluetooth via Plugin.BLE)

Target framework UI framework Supported OS Interfaces
netstandard2.0 Xamarin Windows UWP 10~11 / Android / iOS (no TLS 1.3) BLE / TCP
netstandard2.1 Xamarin Android / iOS (TLS 1.3) BLE / TCP
net10.0 MAUI Windows 10~11 / Android / iOS BLE / TCP

Source build with a build option (Bluetooth via external btframework / WCL library)

Target framework UI framework Supported OS Interfaces
net48 WinForms Windows 7~11 desktop (WinCE/WinXP may be possible) BLE / TCP; USB / Serial Port in design

Source build with a build option (Bluetooth via WinRT API)

Target framework UI framework Supported OS Interfaces
net10.0 (WinForms, net10.0-windows10.0.19041.0) WinForms Windows 10~11 desktop BLE / TCP; Serial Port in design

Notes

  • Published NuGet package (Plugin.BLE flavour only): lib/netstandard2.0, lib/netstandard2.1, lib/net10.0, lib/net10.0-android36.0, lib/net10.0-ios26.0, lib/net10.0-windows10.0.19041 (see nuget/README.md). Mac Catalyst is not a target.
  • HAL selection / build option (current mechanism): net48 selects Source/HAL/btframework (WCL) automatically for that TFM in CSLibrary2026.csproj; the WinRT flavour for a WinForms build uses Source/HAL/WinFormsBLE (Windows Runtime GATT, no third-party dependency) but currently requires manually editing CSLibrary2026.csproj ItemGroups (see BLE HAL selection / Building the WinForms flavours from source). A command-line build option/switch is not implemented yet. BLE HALs are mutually exclusive (each provides the same HighLevelInterface partial members and CSLibrary.DeviceFinder API).
  • Not published to NuGet: the net48 (btframework) flavour sets IncludeBuildOutput=false/SuppressDependenciesWhenPacking=true; the WinFormsBLE flavour is not compiled into the default project/package and would require a separate package id to ship (MAUI Windows and WinForms on .NET 10 both resolve net10.0-windows*).
  • USB / Serial Port: in design, not implemented yet. The embedded legacy engine stubs these transports (Source/Legacy/CSLibrary.Comm/CodeFileCommUnsupported.cs); Windows-only reference implementation is in S:\Projects\GitHub\CSLibrary\CSLibrary.
  • Connect API signatures differ by HAL: e.g. Plugin.BLE ConnectAsync(IAdapter, IDevice, READERPROTOCOL), btframework ConnectAsync(object macAdd, READERPROTOCOL), WinFormsBLE ConnectAsync(BluetoothLEDevice, READERPROTOCOL)—applications must follow the selected HAL/API.
  • Platform intent: prefer a single CSLibrary2026.csproj to keep behavior consistent across existing UI/app variants; evaluate multi-targeting/conditions first and split project files only if required while sharing Source/ where possible. ARM Linux support is planned (no Linux TFM in CSLibrary2026.csproj yet).

Features

  • Bluetooth LE (BLE) communication via Plugin.BLE
  • TCP/IP connectivity for fixed readers (Windows desktop)
  • Multi-reader support across CSL RFID readers
  • Rich RFID operations: inventory, read/write, lock/kill, filtering
  • Barcode scanning integration
  • Battery & notification management

Installation

dotnet add package CSLibrary2026

Or add to your .csproj:

<PackageReference Include="CSLibrary2026" Version="1.0.0-beta.1" />

Quick Start

1. Connect to a Reader

Find the readers

The unified search finds the readers of every requested interface and reports them in the same shape. The protocol of the reader (NET_CSLEx10, NET_DIRECTRx000, BT_CSLRx000, BT_CSLEx10) decides how the reader is connected.

using CSLibrary.NetFinder;

RFIDReaderFinder.OnReaderFound += (sender, e) =>
{
    RFIDReaderInfo reader = e.Reader;

    Console.WriteLine($"{reader.Protocol} {reader.DeviceName} {reader.IPAddress}");
};

// Every interface, or a selection:
// RFIDReaderFinder.SearchDevice(READERINTERFACE.NETWORK, READERINTERFACE.BLUETOOTH);
RFIDReaderFinder.SearchDevice();

Bluetooth LE (CS108, CS468, CS710S, CS203XL)

using CSLibrary;
using CSLibrary.NetFinder;

// Create the reader instance
var reader = new HighLevelInterface();

// Hand the BLE adapter of the platform over to the library
CSLibrary.DeviceFinder.Initialize(adapter, bluetoothLe);

// Discover BLE devices
CSLibrary.DeviceFinder.OnDeviceFound += (sender, device) =>
{
    Console.WriteLine($"Found: {device.Name}");
};
CSLibrary.DeviceFinder.StartDeviceSearch();

// Connect to a BLE reader
await reader.ConnectAsync(adapter, device, READERPROTOCOL.BT_CSLRx000);

TCP/IP (CS203XL - Network API)

using CSLibrary;
using CSLibrary.NetFinder;

// Create the reader instance
var reader = new HighLevelInterface();

// Connect via TCP/IP (CS203XL Network API)
await reader.ConnectAsync("192.168.1.100", READERPROTOCOL.NET_CSLEx10);

2. Subscribe to Events

// RFID tag inventory callback
reader.rfid.OnAsyncCallback += (sender, e) =>
{
    if (e.type == Constants.CallbackType.TAG_RANGING)
    {
        Console.WriteLine($"EPC: {e.info.epc}");
    }
};

// Reader state change callback
reader.OnReaderStateChanged += (sender, e) =>
{
    Console.WriteLine($"State: {e.state}");
};

3. Start Inventory

// Set power level (0–3000 = 0–30.00 dBm)
reader.rfid.SetPowerLevel(3000);

// Start inventory
reader.rfid.StartOperation(RFIDReader.Operation.TAG_RANGING);

// Stop after some time
reader.rfid.StopOperation();

API Overview

Connection

Method Description
ConnectAsync(IAdapter, IDevice, READERPROTOCOL) Connect to a BLE reader
ConnectAsync(string ipAddress, READERPROTOCOL) Connect to a TCP/IP reader
DisconnectAsync() Disconnect from the reader (BLE or TCP, decided internally)

Migrating from the previous CSLibrary / CSLibrary2026: this package is the unified API, so a few signatures differ from the older per-HAL implementations. The most common one is DisconnectAsync(), which used to be async Task<bool> and is now void (the transport is selected internally). Drop the discard when updating an existing app:

-_ = reader.DisconnectAsync();   // previous CSLibrary2026 (Task<bool>)
+reader.DisconnectAsync();        // CSLibrary2026 (unified API)

Applications are expected to follow the library; if an app fails to compile, adjust the app rather than the library signature.

RFID Operations

Start operations:

reader.rfid.StartOperation(Operation.TAG_RANGING);       // Inventory
reader.rfid.StartOperation(Operation.TAG_READ);           // Read tags
reader.rfid.StartOperation(Operation.TAG_READ_TID);       // Read TID bank
reader.rfid.StartOperation(Operation.TAG_READ_USER);      // Read USER bank
reader.rfid.StartOperation(Operation.TAG_WRITE);         // Write tags
reader.rfid.StartOperation(Operation.TAG_LOCK);           // Lock tag
reader.rfid.StartOperation(Operation.TAG_KILL);           // Kill tag
reader.rfid.StopOperation();                             // Stop continuous operation

Power & Frequency:

reader.rfid.SetPowerLevel(uint pwrlevel);           // Set power (0–3000)
reader.rfid.GetActiveMaxPowerLevel();               // Get max power
reader.rfid.SetCurrentLinkProfile(uint profile);    // Set link profile
reader.rfid.SetCountry(string countryName);         // Set country frequency
reader.rfid.SetCountry(string countryName, int ch);// Set country + fixed channel

Singulation Algorithms:

reader.rfid.SetCurrentSingulationAlgorithm(SingulationAlgorithm.FIXEDQ);
reader.rfid.SetFixedQParms(FixedQParms parms);
reader.rfid.SetDynamicQParms(DynamicQParms parms);
reader.rfid.SetTagGroup(TagGroup tagGroup);
reader.rfid.SetPostMatchCriteria(SingulationCriterion[] criteria);

Callback Events:

  • reader.rfid.OnAsyncCallback — Inventory / tag data (CallbackType.TAG_RANGING, TAG_SEARCHING)
  • reader.rfid.OnAccessCompleted — Read/write/lock result
  • reader.OnReaderStateChanged — RFID reader state

Battery & Notifications

reader.GetCurrentBatteryLevel();              // Get battery level
reader.ClearEventHandler();                   // Clear all callback events

reader.notification.OnVoltageEvent += ...     // Battery level changes
reader.notification.OnKeyEvent += ...         // Hotkey presses

Barcode Scanner

reader.barcode.OnCapturedNotify += (sender, e) => Console.WriteLine($"Barcode: {e.Barcode}");
reader.barcode.Start();
reader.barcode.Stop();

Events:

  • OnCapturedNotify — Captured barcode data
  • OnStateChanged — Scanner state

Reader protocol branches

The unified API splits the readers into protocol branches; StartOperation and the rest of the API dispatch to the branch that matches the connected reader model:

Branch Readers Protocol
RX000 CS108, CS468 CSL command set over Bluetooth LE (Source/RFIDReader/Comm_Protocol/RX000Commands/)
Ex10 CS710S, CS203XL CSL command set over Bluetooth LE / TCP/IP (Source/RFIDReader/Comm_Protocol/Ex10Commands/)
Legacy CS463, CS203X, CS468, CS468INT, CS468X, CS468XJ Impinj R1000/R2000 MAC register protocol over the Intel low level API (TCP port 1515)

The Legacy branch is the original CSL reader library (the CSLibrary repository), embedded in this assembly under Source/Legacy/ and reachable through the top level CSLegacy.* namespaces (deliberately not CSLibrary.Legacy, so the unified types of the same name are not shadowed). It is used as the protocol engine of the branch; the unified API stays the only public surface and converts every type on the way in and out (Source/RFIDReader/CSLUnifiedAPI/Legacy_API/).

Those readers do not speak the CSL command set, so they need their own socket: the legacy engine implements the Intel low level API itself. Connect to them with the protocol aware overload:

await reader.ConnectAsync("192.168.25.194", CSLibrary.NetFinder.READERPROTOCOL.NET_DIRECTRx000);

The protocol selects the protocol implementation: NET_DIRECTRx000 drives the legacy engine, which detects the reader model from its OEM information, and NET_CSLEx10 drives the CSL command set on the port 1525. The reader model is available through reader.rfid.GetModel() once the reader has answered.

The readers of this family answer the discovery broadcast on UDP port 3040, while the CS203XL answers on UDP port 3050. The unified reader search (CSLibrary.NetFinder.RFIDReaderFinder) listens on both, so an app does not have to know the broadcast of the reader family:

using CSLibrary.NetFinder;

RFIDReaderFinder.OnReaderFound += (sender, e) =>
{
    RFIDReaderInfo reader = e.Reader;

    Console.WriteLine($"{reader.Protocol} {reader.DeviceName} {reader.IPAddress}");
};

RFIDReaderFinder.SearchDevice(READERINTERFACE.NETWORK);

See Documents/READER_DISCOVERY.md for the whole search API.

Diagnosing the legacy branch

Two helpers are available for the R1000/R2000 family (CS463 / CS203X / CS468):

  • RFIDReader.InventoryTest(uint milliseconds, out uint tagCount) - starts an inventory, waits for the given time and stops it again, and reports how many tags the reader returned. It is the quickest way to tell a reader problem apart from a library problem.
  • CSLegacy.Diagnostics.LegacyTrace - an opt-in trace of every MAC register the legacy engine reads from or writes to the reader. The output goes to System.Diagnostics.Debug, so it appears in the "Output" window of Visual Studio while a debugger is attached (Debug > Windows > Output, source "Debug"). It is switched on automatically when a debugger is attached, or by the environment variable CSL_LEGACY_TRACE=1, or by CSLegacy.Diagnostics.LegacyTrace.Enabled = true. The other reader models do not use the MAC register protocol and are not traced.

While the reader is connected, the legacy engine also runs a short inventory test at each step of the connect sequence and writes the result to the trace ([CSLegacy] INVTEST <step> -> result=OK tags=129). Those tests are meant to locate the step that stops the reader from inventorying; they are off by default (they would add about twelve seconds to every connect) and are switched on with CSLegacy.HighLevelInterface.ConnectInventoryTestDuration = 1000;.

API Reference Manual

The application programming interface is documented in Documents/API_Manual/. The manual is a static site: open Documents/API_Manual/index.html in a browser, no web server is needed, and the search works offline.

pwsh -File Documents/API_Manual/build-docs.ps1

The script regenerates the API reference pages from the compiled library and its XML documentation, and rebuilds the search index. The guides are written by hand and are not touched by the build.

Project Structure

CSLibrary2026/
├── Source/
│   ├── CSLibrary.cs                     # Main library entry point
│   ├── Transport/                       # Transport layer abstraction (ITransport, BLE/TCP)
│   ├── BluetoothProtocol/               # BLE protocol (send/receive/connect)
│   ├── HAL/
│   │   ├── Plugin.BLE/                  # BLE backend (Plugin.BLE)
│   │   └── TCPIP/                       # TCP/IP backend
│   ├── Legacy/                           # Legacy CSL reader engine (CS463 / CS203X / CS468 branch)
│   ├── RFIDReader/
│   │   ├── Comm_Protocol/               # Low-level command protocols (Ex10Commands, RX000Commands)
│   │   └── CSLUnifiedAPI/               # Unified API and reader-specific implementations
│   │   └── Legacy_API/             # Bridge to the legacy engine (CS463 / CS203X / CS468)
│   │       └── Basic_API/
│   │           ├── CS108/               # CS108 / CS468 (Rx-family) implementation
│   │           └── CS710S/              # CS710S / CS203XL (Ex10-family) implementation
│   ├── BarcodeReader/                   # Barcode scanning
│   ├── Battery/                         # Battery management
│   ├── BluetoothIC/                     # Bluetooth IC control
│   ├── Notification/                    # System notifications
│   ├── SiliconLabIC/                    # Silicon Lab IC support
│   ├── SystemInformation/               # Device/country/frequency information
│   └── Tools/                           # Utilities
└── Documents/                           # Hardware/protocol specs and internal notes

Architecture

CSLibrary2026 uses a transport abstraction layer (ITransport) to support both Bluetooth LE and TCP/IP connections:

HighLevelInterface
├── rfid          — RFID operations (inventory, read/write, lock/kill)
├── barcode       — Barcode scanning
├── notification  — Battery, key events
└── _transport    — ITransport (BLETransport or TCPTransport)

ITransport
├── ConnectAsync()  — Connect via BLE or TCP
├── SendAsync()     — Send command data
├── Disconnect()    — Close connection
└── SetReceiveCallback() — Handle incoming data

Reader discovery is unified: CSLibrary.NetFinder.RFIDReaderFinder searches the selected interfaces (TCP/IP, Bluetooth LE, and later Serial and USB) and reports every reader in the same shape, with the protocol of the reader (CSLibrary.NetFinder.READERPROTOCOL). See Documents/READER_DISCOVERY.md.

BLE HAL selection

See Build flavours for the flavour/HAL matrix and notes. The BLE HALs are interchangeable but mutually exclusive: only one is compiled into a given binary because they define the same HighLevelInterface partial members and the same CSLibrary.DeviceFinder API. A command-line build option/switch is not implemented yet (see Building the WinForms flavours from source for the required CSLibrary2026.csproj ItemGroup changes).

Packaging facts: the published NuGet package contains the Plugin.BLE flavours only (lib/netstandard2.0, lib/netstandard2.1, lib/net10.0, lib/net10.0-android36.0, lib/net10.0-ios26.0, lib/net10.0-windows10.0.19041 for the Windows head of a MAUI app; see nuget/README.md). The net48 flavour is excluded from the package (IncludeBuildOutput=false and SuppressDependenciesWhenPacking=true for that target framework), so the package contains no lib/net48 folder and no .NETFramework4.8 dependency group. The WinFormsBLE flavour is not compiled into the default project/package.

Publishing to NuGet

The publishing assets live in nuget/:

# Build the package only
pwsh -File nuget/scripts/Publish-NuGet.ps1 -Version 2.0.0-beta.3 -SkipPush

# Build and push to NuGet.org
pwsh -File nuget/scripts/Publish-NuGet.ps1 -Version 2.0.0-beta.3 -ApiKey $env:NUGET_API_KEY
./nuget/scripts/publish-nuget.sh 2.0.0-beta.3

The GitHub Actions workflow .github/workflows/publish-nuget.yml publishes automatically on a GitHub release: it packs the Linux and macOS target frameworks in two jobs (Apple targets only build on macOS), merges them into one package and pushes it to NuGet.org. It needs a NUGET_API_KEY repository secret.

Building the WinForms flavours from source

Both WinForms flavours are used by downloading the source and switching the HAL in CSLibrary2026.csproj, then rebuilding:

WinForms on .NET Framework 4.8 — btframework (already the default for net48):

<ItemGroup Condition=" '$(TargetFramework)' == 'net48' ">
  <Compile Remove="Source/HAL/Plugin.BLE/**" />
  <Compile Include="Source/HAL/btframework/**/*.cs" />
  <Compile Remove="Source/Transport/BLETransport.cs" />
  <!-- WCL references: Source\HAL\btframework\wclBluetoothFramework.dll, wclCommon.dll,
       wclCommunication.dll -->
</ItemGroup>

WinForms on .NET 10 — WinFormsBLE (Windows Runtime GATT, no third party dependency):

<ItemGroup Condition=" '$(TargetFramework)' == 'net10.0-windows10.0.19041.0' ">
  <Compile Remove="Source/HAL/Plugin.BLE/**" />
  <Compile Include="Source/HAL/WinFormsBLE/**/*.cs" />
  <Compile Remove="Source/Transport/BLETransport.cs" />
</ItemGroup>

Note that a MAUI application and a WinForms application on .NET 10 resolve to the same net10.0-windows* target framework, so a single NuGet package cannot serve the WinFormsBLE HAL to WinForms while serving Plugin.BLE to MAUI. WinForms on .NET 10 therefore builds the library from source.

License

MIT License. See LICENSE for details.

Links

About

No description, website, or topics provided.

Resources

Stars

0 stars

Watchers

0 watching

Forks

Releases

Packages

Contributors

Languages