![]() |
VOOZH | about |
dotnet add package Linux.Bluetooth --version 5.67.1
NuGet\Install-Package Linux.Bluetooth -Version 5.67.1
<PackageReference Include="Linux.Bluetooth" Version="5.67.1" />
<PackageVersion Include="Linux.Bluetooth" Version="5.67.1" />Directory.Packages.props
<PackageReference Include="Linux.Bluetooth" />Project file
paket add Linux.Bluetooth --version 5.67.1
#r "nuget: Linux.Bluetooth, 5.67.1"
#:package Linux.Bluetooth@5.67.1
#addin nuget:?package=Linux.Bluetooth&version=5.67.1Install as a Cake Addin
#tool nuget:?package=Linux.Bluetooth&version=5.67.1Install as a Cake Tool
The Linux.Bluetooth library for .NET gives developers the ability to quickly stand up and interface with Linux's BLE radio with very little effort. There's no need to recall the laborious D-Bus API calls, we handle that for you.
👁 Linux.Bluetooth NuGet Version
The library uses, Tmds.DBus to access Linux's D-Bus, the preferred interface for Bluetooth in userspace.
Check out the SuessLabs article on using Linux.Bluetooth
Sorry, older Mono (.NET Framework) versions are not supported.
This project has been validated against, BlueZ v5.50 and above. You can check which version you're using with, bluetoothd -v.
Linux.Bluetooth aims to support Linux Distributions where both .NET and BlueZ is supported. Officially, this NuGet package has been tested against Ubuntu 20.04 LTS.
List of BlueZ supported distros:
dotnet add package Linux.Bluetooth
C# events are available for several properties. Events are useful for properly handling disconnects and reconnects.
using Linux.Bluetooth;
...
IAdapter1 adapter = (await BlueZManager.GetAdaptersAsync()).FirstOrDefault();
or get a particular adapter:
IAdapter1 adapter = await BlueZManager.GetAdapterAsync(adapterName: "hci0");
adapter.DeviceFound += adapter_DeviceFoundAsync;
await adapter.StartDiscoveryAsync();
...
await adapter.StopDiscoveryAsync();
adapter.DeviceFound (above) will be called immediately for existing devices, and as new devices show up during scanning; eventArgs.IsStateChange can be used to distinguish between existing and new devices. Alternatively you can can use GetDevicesAsync:
IReadOnlyList<Device> devices = await adapter.GetDevicesAsync();
device.Connected += device_ConnectedAsync;
device.Disconnected += device_DisconnectedAsync;
device.ServicesResolved += device_ServicesResolvedAsync;
await device.ConnectAsync();
Alternatively, you can wait for "Connected" and "ServicesResolved" to equal true:
TimeSpan timeout = TimeSpan.FromSeconds(15);
await device.ConnectAsync();
await device.WaitForPropertyValueAsync("Connected", value: true, timeout);
await device.WaitForPropertyValueAsync("ServicesResolved", value: true, timeout);
Prerequisite: You must be connected to a device and services must be resolved. You may need to pair with the device in order to use some services.
Example using GATT Device Information Service UUIDs.
string serviceUUID = "0000180a-0000-1000-8000-00805f9b34fb";
string characteristicUUID = "00002a24-0000-1000-8000-00805f9b34fb";
IGattService1 service = await device.GetServiceAsync(serviceUUID);
IGattCharacteristic1 characteristic = await service.GetCharacteristicAsync(characteristicUUID);
byte[] value = await characteristic.ReadValueAsync(timeout);
string modelName = Encoding.UTF8.GetString(value);
characteristic.Value += characteristic_Value;
...
private static async Task characteristic_Value(GattCharacteristic characteristic, GattCharacteristicValueEventArgs e)
{
try
{
Console.WriteLine($"Characteristic value (hex): {BitConverter.ToString(e.Value)}");
Console.WriteLine($"Characteristic value (UTF-8): \"{Encoding.UTF8.GetString(e.Value)}\"");
}
catch (Exception ex)
{
Console.Error.WriteLine(ex);
}
}
It may be necessary to pair with a device for a GATT service to be visible or for reading GATT characteristics to work. To pair, one option is to run bluetoothctl (or sudo bluetoothctl)
and then run default agent and agent on within bluetoothctl. Watch bluetoothctl for pairing requests.
See Ubuntu's Introduction to Pairing.
From command line, use bluetoothctl or Bluetooth Manager to scan and retrieve device UUIDs and Services to assist with debugging.."
$ bluetoothctl
; Get list of BT Adapters
list
; Scan for devices
scan on
; Stop Scanning
scan off
; List known devices
devices
See .
Linux.Bluetooth.Extensions. It will now just be Linux.Bluetooth namespace.Sponsored by: Suess Labs a subsidary of Xeno Innovations, Inc.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 net5.0 was computed. net5.0-windows net5.0-windows was computed. net6.0 net6.0 was computed. net6.0-android net6.0-android was computed. net6.0-ios net6.0-ios was computed. net6.0-maccatalyst net6.0-maccatalyst was computed. net6.0-macos net6.0-macos was computed. net6.0-tvos net6.0-tvos was computed. net6.0-windows net6.0-windows was computed. net7.0 net7.0 was computed. net7.0-android net7.0-android was computed. net7.0-ios net7.0-ios was computed. net7.0-maccatalyst net7.0-maccatalyst was computed. net7.0-macos net7.0-macos was computed. net7.0-tvos net7.0-tvos was computed. net7.0-windows net7.0-windows was computed. net8.0 net8.0 was computed. net8.0-android net8.0-android was computed. net8.0-browser net8.0-browser was computed. net8.0-ios net8.0-ios was computed. net8.0-maccatalyst net8.0-maccatalyst was computed. net8.0-macos net8.0-macos was computed. net8.0-tvos net8.0-tvos was computed. net8.0-windows net8.0-windows was computed. net9.0 net9.0 was computed. net9.0-android net9.0-android was computed. net9.0-browser net9.0-browser was computed. net9.0-ios net9.0-ios was computed. net9.0-maccatalyst net9.0-maccatalyst was computed. net9.0-macos net9.0-macos was computed. net9.0-tvos net9.0-tvos was computed. net9.0-windows net9.0-windows was computed. net10.0 net10.0 was computed. net10.0-android net10.0-android was computed. net10.0-browser net10.0-browser was computed. net10.0-ios net10.0-ios was computed. net10.0-maccatalyst net10.0-maccatalyst was computed. net10.0-macos net10.0-macos was computed. net10.0-tvos net10.0-tvos was computed. net10.0-windows net10.0-windows was computed. |
| .NET Core | netcoreapp2.0 netcoreapp2.0 was computed. netcoreapp2.1 netcoreapp2.1 was computed. netcoreapp2.2 netcoreapp2.2 was computed. netcoreapp3.0 netcoreapp3.0 was computed. netcoreapp3.1 netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 netstandard2.0 is compatible. netstandard2.1 netstandard2.1 was computed. |
| .NET Framework | net461 net461 was computed. net462 net462 was computed. net463 net463 was computed. net47 net47 was computed. net471 net471 was computed. net472 net472 was computed. net48 net48 was computed. net481 net481 was computed. |
| MonoAndroid | monoandroid monoandroid was computed. |
| MonoMac | monomac monomac was computed. |
| MonoTouch | monotouch monotouch was computed. |
| Tizen | tizen40 tizen40 was computed. tizen60 tizen60 was computed. |
| Xamarin.iOS | xamarinios xamarinios was computed. |
| Xamarin.Mac | xamarinmac xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos xamarinwatchos was computed. |
Showing the top 3 NuGet packages that depend on Linux.Bluetooth:
| Package | Downloads |
|---|---|
|
InTheHand.Net.Bluetooth
32feet.NET is an open-source project to make personal area networking technologies such as Bluetooth easily accessible from .NET code. |
|
|
InTheHand.BluetoothLE
32feet.NET is an open-source project to make personal area networking technologies such as Bluetooth easily accessible from .NET code. |
|
|
NRuuviTag.Listener.Linux
Linux BlueZ-based listener for NRuuviTag - a library for reading Ruuvi IoT sensor data. |
Showing the top 1 popular GitHub repositories that depend on Linux.Bluetooth:
| Repository | Stars |
|---|---|
|
inthehand/32feet
Personal Area Networking for .NET. Open source and professionally supported
|
| Version | Downloads | Last Updated |
|---|---|---|
| 6.0.0-pre3 | 328 | 4/10/2026 |
| 6.0.0-pre2 | 3,446 | 4/21/2025 |
| 6.0.0-pre1 | 259 | 4/21/2025 |
| 5.67.1 | 94,711 | 9/8/2024 |
| 5.67.0 | 704 | 9/7/2024 |
| 5.66.0 | 83,739 | 1/11/2024 |
| 5.64.0 | 21,597 | 7/26/2022 |
Upgraded DBus support.