Interface IBluetoothCharacteristicAccessor<TRead, TWrite>
- Namespace
- Bluetooth.Abstractions.Scanning.Profiles
- Assembly
- Bluetooth.Abstractions.Scanning.dll
Defines typed read and write operations for a specific remote Bluetooth characteristic.
public interface IBluetoothCharacteristicAccessor<TRead, in TWrite> : IBluetoothCharacteristicAccessor
Type Parameters
TReadThe typed value produced when reading the characteristic.
TWriteThe typed value accepted when writing the characteristic.
- Inherited Members
- Extension Methods
Methods
CanListen(IBluetoothRemoteDevice)
Determines whether the resolved characteristic supports notifications/indications.
bool CanListen(IBluetoothRemoteDevice device)
Parameters
deviceIBluetoothRemoteDeviceThe connected remote device that owns the characteristic.
Returns
- bool
truewhen the characteristic is already resolved and listenable; otherwisefalse.
CanRead(IBluetoothRemoteDevice)
Determines whether the resolved characteristic can be read.
bool CanRead(IBluetoothRemoteDevice device)
Parameters
deviceIBluetoothRemoteDeviceThe connected remote device that owns the characteristic.
Returns
- bool
truewhen the characteristic is already resolved and readable; otherwisefalse.
CanWrite(IBluetoothRemoteDevice)
Determines whether the resolved characteristic can be written.
bool CanWrite(IBluetoothRemoteDevice device)
Parameters
deviceIBluetoothRemoteDeviceThe connected remote device that owns the characteristic.
Returns
- bool
truewhen the characteristic is already resolved and writable; otherwisefalse.
ReadAsync(IBluetoothRemoteDevice, bool, TimeSpan?, CancellationToken)
Reads and decodes the typed value from the characteristic.
ValueTask<TRead> ReadAsync(IBluetoothRemoteDevice device, bool skipIfPreviouslyRead = false, TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
deviceIBluetoothRemoteDeviceThe connected remote device that owns the characteristic.
skipIfPreviouslyReadboolWhen true, skips the native read if a previous value is already cached.
timeoutTimeSpan?Optional timeout for exploration and read operations.
cancellationTokenCancellationTokenToken used to cancel the operation.
Returns
- ValueTask<TRead>
The decoded typed value.
WriteAsync(IBluetoothRemoteDevice, TWrite, bool, TimeSpan?, CancellationToken)
Encodes and writes the typed value to the characteristic.
ValueTask WriteAsync(IBluetoothRemoteDevice device, TWrite value, bool skipIfOldValueMatchesNewValue = false, TimeSpan? timeout = null, CancellationToken cancellationToken = default)
Parameters
deviceIBluetoothRemoteDeviceThe connected remote device that owns the characteristic.
valueTWriteThe typed value to encode and write.
skipIfOldValueMatchesNewValueboolWhen true, skips the native write if current and new values match.
timeoutTimeSpan?Optional timeout for exploration and write operations.
cancellationTokenCancellationTokenToken used to cancel the operation.