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
adapterIBluetoothAdapterThe Bluetooth adapter to associate with this broadcaster.
tickerITickerThe ticker for scheduling periodic refresh tasks.
loggerFactoryILoggerFactoryOptional logger factory for creating loggers.
Exceptions
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
idGuidnamestringisPrimarybooltimeoutTimeSpan?cancellationTokenCancellationToken
Returns
Exceptions
NativeHasBroadcasterPermissionsAsync()
Platform-specific implementation to check if broadcaster permissions are granted.
protected override ValueTask<bool> NativeHasBroadcasterPermissionsAsync()
Returns
Remarks
Implement platform-specific permission checks. Should NOT throw exceptions. Return false if permissions cannot be determined.
Exceptions
NativeRefreshIsRunning()
Refreshes the native running state from the underlying platform.
protected override void NativeRefreshIsRunning()
Exceptions
NativeRequestBroadcasterPermissionsAsync(CancellationToken)
Platform-specific implementation to request broadcaster permissions.
protected override ValueTask NativeRequestBroadcasterPermissionsAsync(CancellationToken cancellationToken)
Parameters
cancellationTokenCancellationTokenCancellation token to cancel the permission request operation.
Returns
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
optionsBroadcastingOptionstimeoutTimeSpan?cancellationTokenCancellationToken
Returns
Exceptions
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
timeoutTimeSpan?cancellationTokenCancellationToken