Table of Contents

Class DotNetCoreBluetoothBroadcaster

Namespace
Bluetooth.Maui.Platforms.DotNetCore.Broadcasting
Assembly
Bluetooth.Maui.Platforms.DotNetCore.dll

Base class for Bluetooth Low Energy broadcaster implementations that advertise the device's presence.

public class DotNetCoreBluetoothBroadcaster : BaseBluetoothBroadcaster, INotifyPropertyChanged, IBluetoothBroadcaster, IAsyncDisposable
Inheritance
DotNetCoreBluetoothBroadcaster
Implements
Inherited Members

Remarks

Broadcasters allow a device to act as a BLE peripheral, advertising its presence and services to nearby devices. This is the opposite role of a scanner, which listens for advertisements.

Constructors

DotNetCoreBluetoothBroadcaster(IBluetoothAdapter, ITicker, ILoggerFactory?)

Initializes a new instance of the BaseBluetoothBroadcaster class.

public DotNetCoreBluetoothBroadcaster(IBluetoothAdapter adapter, ITicker ticker, ILoggerFactory? loggerFactory = null)

Parameters

adapter IBluetoothAdapter

The Bluetooth adapter to associate with this broadcaster.

ticker ITicker

The ticker for scheduling periodic refresh tasks.

loggerFactory ILoggerFactory

Optional logger factory for creating loggers.

Exceptions

PlatformNotSupportedException

Methods

NativeCreateServiceAsync(Guid, string?, bool, TimeSpan?, CancellationToken)

Creates a new local Bluetooth service with the specified parameters.

protected override ValueTask<IBluetoothLocalService> NativeCreateServiceAsync(Guid id, string? name = null, bool isPrimary = true, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

id Guid
name string
isPrimary bool
timeout TimeSpan?
cancellationToken CancellationToken

Returns

ValueTask<IBluetoothLocalService>

Exceptions

PlatformNotSupportedException

NativeHasBroadcasterPermissionsAsync()

Platform-specific implementation to check if broadcaster permissions are granted.

protected override ValueTask<bool> NativeHasBroadcasterPermissionsAsync()

Returns

ValueTask<bool>

True if permissions are granted, otherwise false.

Remarks

Implement platform-specific permission checks. Should NOT throw exceptions. Return false if permissions cannot be determined.

Exceptions

PlatformNotSupportedException

NativeRefreshIsRunning()

Refreshes the native running state from the underlying platform.

protected override void NativeRefreshIsRunning()

Exceptions

PlatformNotSupportedException

NativeRequestBroadcasterPermissionsAsync(CancellationToken)

Platform-specific implementation to request broadcaster permissions.

protected override ValueTask NativeRequestBroadcasterPermissionsAsync(CancellationToken cancellationToken)

Parameters

cancellationToken CancellationToken

Cancellation token to cancel the permission request operation.

Returns

ValueTask

Remarks

Implement platform-specific permission request dialogs. Throw native exceptions on failure - base class will wrap them in BluetoothPermissionException.

Exceptions

Exception

Throw platform-specific exceptions on failure.

PlatformNotSupportedException

NativeStartAsync(BroadcastingOptions, TimeSpan?, CancellationToken)

Starts the native Bluetooth broadcaster with the specified options. This method is called by StartBroadcastingAsync(BroadcastingOptions?, PermissionOptions?, TimeSpan?, CancellationToken) to perform platform-specific start operations.

protected override ValueTask NativeStartAsync(BroadcastingOptions options, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

options BroadcastingOptions
timeout TimeSpan?
cancellationToken CancellationToken

Returns

ValueTask

Exceptions

PlatformNotSupportedException

NativeStopAsync(TimeSpan?, CancellationToken)

Stops the native Bluetooth broadcaster. This method is called by StopBroadcastingAsync(TimeSpan?, CancellationToken) to perform platform-specific stop operations.

protected override ValueTask NativeStopAsync(TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

timeout TimeSpan?
cancellationToken CancellationToken

Returns

ValueTask

Exceptions

PlatformNotSupportedException