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
parentServiceIBluetoothRemoteServiceThe Bluetooth service associated with this characteristic.
idGuidThe unique identifier for the characteristic.
nameProviderIBluetoothNameProviderAn optional provider for characteristic names, used to resolve the name based on the ID.
loggerILogger<IBluetoothRemoteCharacteristic>The logger instance to use for logging (optional).
Exceptions
- ArgumentNullException
Thrown when
parentServiceis null.- PlatformNotSupportedException
Methods
NativeAbortReliableWriteAsync()
Platform-specific implementation to abort a reliable write transaction.
protected override ValueTask NativeAbortReliableWriteAsync()
Returns
Exceptions
NativeBeginReliableWriteAsync()
Platform-specific implementation to begin a reliable write transaction.
protected override ValueTask NativeBeginReliableWriteAsync()
Returns
Exceptions
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
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
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
NativeDescriptorsExplorationAsync(TimeSpan?, CancellationToken)
Platform-specific implementation to explore (discover) descriptors.
protected override ValueTask NativeDescriptorsExplorationAsync(TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
timeoutTimeSpan?cancellationTokenCancellationToken
Returns
Exceptions
NativeExecuteReliableWriteAsync()
Platform-specific implementation to execute a reliable write transaction.
protected override ValueTask NativeExecuteReliableWriteAsync()
Returns
Exceptions
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
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
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
shouldBeListeningboolTrue 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
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
valueReadOnlyMemory<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.