Bluez.NET.Server 0.0.2

There is a newer version of this package available.
See the version list below for details.
dotnet add package Bluez.NET.Server --version 0.0.2
                    
NuGet\Install-Package Bluez.NET.Server -Version 0.0.2
                    
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Bluez.NET.Server" Version="0.0.2" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Bluez.NET.Server" Version="0.0.2" />
                    
Directory.Packages.props
<PackageReference Include="Bluez.NET.Server" />
                    
Project file
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Bluez.NET.Server --version 0.0.2
                    
#r "nuget: Bluez.NET.Server, 0.0.2"
                    
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Bluez.NET.Server@0.0.2
                    
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Bluez.NET.Server&version=0.0.2
                    
Install as a Cake Addin
#tool nuget:?package=Bluez.NET.Server&version=0.0.2
                    
Install as a Cake Tool

Overview

.NET BlueZ Server is a powerful library designed to facilitate the creation of Bluetooth Low Energy (BLE) peripherals and efficiently manage centrals on Linux using .NET Core. Leveraging the capabilities of BlueZ under the hood, this library offers a seamless API that preserves the object structure of BlueZ while streamlining D-Bus communication for a more developer-friendly experience.

Key features

  • BLE Peripheral Creation
  • Adapter Management
  • Central Management
  • Pair device
  • Remove Device
  • Get all paired devices
  • Get central object path on Read and Write request

Example

Create BLE peripheral

ServerContext _CurrentServerContext = new ServerContext();
await BleAdvertisement.RegisterAdvertisement(_CurrentServerContext);
await BleGattApplication.RegisterGattApplication(_CurrentServerContext);
DeviceManager.SetDevicePropertyListenerAsync(_CurrentServerContext, OnDeviceConnectedAsync);

Listen Central property change

private async void OnDeviceConnectedAsync(IDevice1 device, PropertyChanges changes)
{
    foreach (var change in changes.Changed)
    {
        Console.WriteLine($"{change.Key}:{change.Value}");                  
    }
}

Get BLE Adapter

AdapterManager.GetAdapter(_CurrentServerContext);

Turn ON/OFF BLE Adapter

var isAdapterOn = AdapterManager.SetAdapterPowerOn(_CurrentServerContext);
var isAdapterOff = AdapterManager.SetAdapterPowerOff(_CurrentServerContext);

Get paired devices

var devices = await DeviceManager.GetDeviceListAsync(_CurrentServerContext);

Remove paired device

await DeviceManager.RemoveDeviceAsync(_CurrentServerContext, iDevice);

Get Device from Address

 var device = await DeviceManager.GetDeviceAsync(_CurrentServerContext, address);

Get Device from object path

var device = await DeviceManager.GetDeviceByObject(_CurrentServerContext, address);

Pair device

var paired = await device.GetPairedAsync();
if (!paired)
{
    var response = await DeviceManager.PairDeviceAsync(_CurrentServerContext,device);
}

Useful references

Resource Link
BlueZ GATT API documentation https://git.kernel.org/pub/scm/bluetooth/bluez.git/tree/doc/gatt-api.txt
Presentation BLE on Linux https://elinux.org/images/3/32/Doing_Bluetooth_Low_Energy_on_Linux.pdf
Product Compatible and additional computed target framework versions.
.NET net6.0 is compatible.  net6.0-android was computed.  net6.0-ios was computed.  net6.0-maccatalyst was computed.  net6.0-macos was computed.  net6.0-tvos was computed.  net6.0-windows was computed.  net7.0 is compatible.  net7.0-android was computed.  net7.0-ios was computed.  net7.0-maccatalyst was computed.  net7.0-macos was computed.  net7.0-tvos was computed.  net7.0-windows was computed.  net8.0 is compatible.  net8.0-android was computed.  net8.0-browser was computed.  net8.0-ios was computed.  net8.0-maccatalyst was computed.  net8.0-macos was computed.  net8.0-tvos was computed.  net8.0-windows was computed.  net9.0 was computed.  net9.0-android was computed.  net9.0-browser was computed.  net9.0-ios was computed.  net9.0-maccatalyst was computed.  net9.0-macos was computed.  net9.0-tvos was computed.  net9.0-windows was computed.  net10.0 was computed.  net10.0-android was computed.  net10.0-browser was computed.  net10.0-ios was computed.  net10.0-maccatalyst was computed.  net10.0-macos was computed.  net10.0-tvos was computed.  net10.0-windows was computed. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 299 3/30/2024
0.0.2 189 2/3/2024
0.0.1 174 2/3/2024