Class LinuxBleBackend
BLE backend for Linux using BlueZ over D-Bus.
Implements
Inherited Members
Namespace: MOSAIC.Components.Manager.BLE
Assembly: MOSAIC.dll
Syntax
public sealed class LinuxBleBackend : IBleBackend
Remarks
Requires the Tmds.DBus NuGet package and BlueZ ≥ 5.50 running on the host.
Compiled only when the LINUX_BLE preprocessor symbol is defined.
csproj example:
<PropertyGroup Condition="$([MSBuild]::IsOSPlatform('Linux'))">
<DefineConstants>$(DefineConstants);LINUX_BLE</DefineConstants>
</PropertyGroup>
<PackageReference Include="Tmds.DBus"
Condition="$([MSBuild]::IsOSPlatform('Linux'))" />
Architecture: All BlueZ interaction goes through the system D-Bus bus.
Device discovery uses org.bluez.Adapter1.StartDiscovery then enumerates
managed objects via org.freedesktop.DBus.ObjectManager.GetManagedObjects.
GATT operations use org.bluez.GattCharacteristic1.
Notification delivery uses the PropertiesChanged signal on the characteristic
object path.
Fields
AdapterPath
Declaration
private const string AdapterPath = "/org/bluez/hci0"
Field Value
| Type | Description |
|---|---|
| string |
BluezService
Declaration
private const string BluezService = "org.bluez"
Field Value
| Type | Description |
|---|---|
| string |
_systemBus
Declaration
private Connection? _systemBus
Field Value
| Type | Description |
|---|---|
| Connection |
Methods
GetAvailabilityAsync(CancellationToken)
Declaration
public Task<bool> GetAvailabilityAsync(CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<bool> |
GetBusAsync(CancellationToken)
Gets or lazily opens the system D-Bus connection.
Declaration
private Task<Connection> GetBusAsync(CancellationToken ct)
Parameters
| Type | Name | Description |
|---|---|---|
| CancellationToken | ct |
Returns
| Type | Description |
|---|---|
| Task<Connection> |
ScanAsync(int, CancellationToken)
Declaration
public Task<IReadOnlyList<BleDiscoveredDevice>> ScanAsync(int timeMs, CancellationToken cancellationToken = default)
Parameters
| Type | Name | Description |
|---|---|---|
| int | timeMs | |
| CancellationToken | cancellationToken |
Returns
| Type | Description |
|---|---|
| Task<IReadOnlyList<BleDiscoveredDevice>> |