Table of Contents

Class DotNetCoreBluetoothRemoteCharacteristic

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

Interface representing a Bluetooth characteristic, providing properties and methods for interacting with it.

public class DotNetCoreBluetoothRemoteCharacteristic : BaseBluetoothRemoteCharacteristic, IBluetoothRemoteCharacteristic, INotifyPropertyChanged, IAsyncDisposable
Inheritance
DotNetCoreBluetoothRemoteCharacteristic
Implements
Inherited Members

Constructors

DotNetCoreBluetoothRemoteCharacteristic(IBluetoothRemoteService, Guid, IBluetoothNameProvider?, ILogger<IBluetoothRemoteCharacteristic>?)

Initializes a new instance of the BaseBluetoothRemoteCharacteristic class.

public DotNetCoreBluetoothRemoteCharacteristic(IBluetoothRemoteService parentService, Guid id, IBluetoothNameProvider? nameProvider = null, ILogger<IBluetoothRemoteCharacteristic>? logger = null)

Parameters

parentService IBluetoothRemoteService

The Bluetooth service associated with this characteristic.

id Guid

The unique identifier for the characteristic.

nameProvider IBluetoothNameProvider

An optional provider for characteristic names, used to resolve the name based on the ID.

logger ILogger<IBluetoothRemoteCharacteristic>

The logger instance to use for logging (optional).

Exceptions

ArgumentNullException

Thrown when parentService is null.

PlatformNotSupportedException

Methods

NativeAbortReliableWriteAsync()

Platform-specific implementation to abort a reliable write transaction.

protected override ValueTask NativeAbortReliableWriteAsync()

Returns

ValueTask

Exceptions

PlatformNotSupportedException

NativeBeginReliableWriteAsync()

Platform-specific implementation to begin a reliable write transaction.

protected override ValueTask NativeBeginReliableWriteAsync()

Returns

ValueTask

Exceptions

PlatformNotSupportedException

NativeCanListen()

Platform-specific implementation to determine if the characteristic can listen for notifications.

protected override bool NativeCanListen()

Returns

bool

True if the characteristic supports listening for notifications; otherwise, false.

Exceptions

PlatformNotSupportedException

NativeCanRead()

Platform-specific implementation to determine if the characteristic can be read. This method should check the platform-specific properties to determine read capability.

protected override bool NativeCanRead()

Returns

bool

True if the characteristic supports read operations; otherwise, false.

Exceptions

PlatformNotSupportedException

NativeCanWrite()

Platform-specific implementation to determine if the characteristic can be written to. This method should check the platform-specific properties to determine write capability.

protected override bool NativeCanWrite()

Returns

bool

True if the characteristic supports write operations; otherwise, false.

Exceptions

PlatformNotSupportedException

NativeDescriptorsExplorationAsync(TimeSpan?, CancellationToken)

Platform-specific implementation to explore (discover) descriptors.

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

Parameters

timeout TimeSpan?
cancellationToken CancellationToken

Returns

ValueTask

Exceptions

PlatformNotSupportedException

NativeExecuteReliableWriteAsync()

Platform-specific implementation to execute a reliable write transaction.

protected override ValueTask NativeExecuteReliableWriteAsync()

Returns

ValueTask

Exceptions

PlatformNotSupportedException

NativeReadIsListeningAsync()

Platform-specific implementation to read the current listening state of the characteristic. This method should initiate the platform-specific operation to query whether notifications/indications are enabled.

protected override ValueTask NativeReadIsListeningAsync()

Returns

ValueTask

A task that completes when the native read operation is initiated.

Remarks

Implementations should call OnReadIsListeningSucceeded(bool) when the operation succeeds or OnReadIsListeningFailed(Exception) when it fails.

Exceptions

PlatformNotSupportedException

NativeReadValueAsync()

Platform-specific implementation to read the characteristic's value. This method should initiate the platform-specific operation to read the characteristic value.

protected override ValueTask NativeReadValueAsync()

Returns

ValueTask

A task that completes when the native read operation is initiated.

Remarks

Implementations should call OnReadValueSucceeded(ReadOnlyMemory<byte>) when the operation succeeds or OnReadValueFailed(Exception) when it fails.

Exceptions

PlatformNotSupportedException

NativeWriteIsListeningAsync(bool)

Platform-specific implementation to write (set) the listening state of the characteristic. This method should initiate the platform-specific operation to enable or disable notifications/indications.

protected override ValueTask NativeWriteIsListeningAsync(bool shouldBeListening)

Parameters

shouldBeListening bool

True to enable notifications/indications, false to disable them.

Returns

ValueTask

A task that completes when the native write operation is initiated.

Remarks

Implementations should call OnWriteIsListeningSucceeded() when the operation succeeds or OnWriteIsListeningFailed(Exception) when it fails.

Exceptions

PlatformNotSupportedException

NativeWriteValueAsync(ReadOnlyMemory<byte>)

Platform-specific implementation to write the characteristic's value. This method should initiate the platform-specific operation to write the value to the characteristic.

protected override ValueTask NativeWriteValueAsync(ReadOnlyMemory<byte> value)

Parameters

value ReadOnlyMemory<byte>

The value to write to the characteristic.

Returns

ValueTask

A task that completes when the native write operation is initiated.

Remarks

Implementations should call OnWriteValueSucceeded() when the operation succeeds or OnWriteValueFailed(Exception) when it fails.

Exceptions

PlatformNotSupportedException