Table of Contents

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

TRead

The typed value produced when reading the characteristic.

TWrite

The 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

device IBluetoothRemoteDevice

The connected remote device that owns the characteristic.

Returns

bool

true when the characteristic is already resolved and listenable; otherwise false.

CanRead(IBluetoothRemoteDevice)

Determines whether the resolved characteristic can be read.

bool CanRead(IBluetoothRemoteDevice device)

Parameters

device IBluetoothRemoteDevice

The connected remote device that owns the characteristic.

Returns

bool

true when the characteristic is already resolved and readable; otherwise false.

CanWrite(IBluetoothRemoteDevice)

Determines whether the resolved characteristic can be written.

bool CanWrite(IBluetoothRemoteDevice device)

Parameters

device IBluetoothRemoteDevice

The connected remote device that owns the characteristic.

Returns

bool

true when the characteristic is already resolved and writable; otherwise false.

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

device IBluetoothRemoteDevice

The connected remote device that owns the characteristic.

skipIfPreviouslyRead bool

When true, skips the native read if a previous value is already cached.

timeout TimeSpan?

Optional timeout for exploration and read operations.

cancellationToken CancellationToken

Token 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

device IBluetoothRemoteDevice

The connected remote device that owns the characteristic.

value TWrite

The typed value to encode and write.

skipIfOldValueMatchesNewValue bool

When true, skips the native write if current and new values match.

timeout TimeSpan?

Optional timeout for exploration and write operations.

cancellationToken CancellationToken

Token used to cancel the operation.

Returns

ValueTask