Table of Contents

Interface IBluetoothLocalCharacteristic

Namespace
Bluetooth.Abstractions.Broadcasting
Assembly
Bluetooth.Abstractions.Broadcasting.dll

Represents a characteristic in the context of bluetooth broadcasting.

public interface IBluetoothLocalCharacteristic : INotifyPropertyChanged, IAsyncDisposable
Inherited Members

Properties

Id

Gets the unique identifier of the characteristic.

Guid Id { get; }

Property Value

Guid

Name

Gets the name of the characteristic.

string Name { get; }

Property Value

string

Permissions

The permissions of the characteristic.

BluetoothCharacteristicPermissions Permissions { get; init; }

Property Value

BluetoothCharacteristicPermissions

Properties

Gets the GATT properties supported by this characteristic (Read/Write/Notify/Indicate, etc.).

BluetoothCharacteristicProperties Properties { get; init; }

Property Value

BluetoothCharacteristicProperties

Service

Gets the Bluetooth service hosting this characteristic.

IBluetoothLocalService Service { get; }

Property Value

IBluetoothLocalService

SubscribedDevices

Gets the list of client devices that are currently subscribed to notifications/indications from this characteristic.

IReadOnlyList<IBluetoothConnectedDevice> SubscribedDevices { get; }

Property Value

IReadOnlyList<IBluetoothConnectedDevice>

Value

Gets the value of the characteristic as a read-only memory segment. Useful for asynchronous operations.

ReadOnlyMemory<byte> Value { get; }

Property Value

ReadOnlyMemory<byte>

ValueSpan

Gets the value of the characteristic as a read-only span. Useful for high-performance scenarios.

ReadOnlySpan<byte> ValueSpan { get; }

Property Value

ReadOnlySpan<byte>

Methods

CreateDescriptorAsync(Guid, string?, TimeSpan?, CancellationToken)

Adds a descriptor to this characteristic.

ValueTask<IBluetoothLocalDescriptor> CreateDescriptorAsync(Guid id, string? name = null, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

id Guid

The ID of the descriptor to add.

name string

An optional name for the descriptor. If not provided, a default name may be assigned based on the ID or other heuristics.

timeout TimeSpan?

The timeout for this operation.

cancellationToken CancellationToken

A cancellation token to cancel this operation.

Returns

ValueTask<IBluetoothLocalDescriptor>

A task that represents the asynchronous operation. The task result contains the added descriptor.

GetDescriptor(Func<IBluetoothLocalDescriptor, bool>)

Gets a descriptor that matches the specified filter.

IBluetoothLocalDescriptor GetDescriptor(Func<IBluetoothLocalDescriptor, bool> filter)

Parameters

filter Func<IBluetoothLocalDescriptor, bool>

The filter to apply to the descriptors.

Returns

IBluetoothLocalDescriptor

The descriptor that matches the filter.

GetDescriptor(Guid)

Gets a descriptor by its ID.

IBluetoothLocalDescriptor GetDescriptor(Guid id)

Parameters

id Guid

The ID of the descriptor to get.

Returns

IBluetoothLocalDescriptor

The descriptor with the specified ID.

GetDescriptorOrDefault(Func<IBluetoothLocalDescriptor, bool>)

Gets a descriptor that matches the specified filter.

IBluetoothLocalDescriptor? GetDescriptorOrDefault(Func<IBluetoothLocalDescriptor, bool> filter)

Parameters

filter Func<IBluetoothLocalDescriptor, bool>

The filter to apply to the descriptors.

Returns

IBluetoothLocalDescriptor

The descriptor that matches the filter, or null if not found.

GetDescriptorOrDefault(Guid)

Gets a descriptor by its ID.

IBluetoothLocalDescriptor? GetDescriptorOrDefault(Guid id)

Parameters

id Guid

The ID of the descriptor to get.

Returns

IBluetoothLocalDescriptor

The descriptor with the specified ID, or null if not found.

GetDescriptors(Func<IBluetoothLocalDescriptor, bool>?)

Gets all descriptors for this characteristic.

IEnumerable<IBluetoothLocalDescriptor> GetDescriptors(Func<IBluetoothLocalDescriptor, bool>? filter = null)

Parameters

filter Func<IBluetoothLocalDescriptor, bool>

An optional filter to apply to the descriptors.

Returns

IEnumerable<IBluetoothLocalDescriptor>

A collection of descriptors.

HasDescriptor(Func<IBluetoothLocalDescriptor, bool>)

Checks if a descriptor that matches the specified filter exists.

bool HasDescriptor(Func<IBluetoothLocalDescriptor, bool> filter)

Parameters

filter Func<IBluetoothLocalDescriptor, bool>

The filter to apply to the descriptors.

Returns

bool

True if a descriptor that matches the specified filter exists; otherwise, false.

HasDescriptor(Guid)

Checks if a descriptor with the specified ID exists.

bool HasDescriptor(Guid id)

Parameters

id Guid

The ID of the descriptor to check for.

Returns

bool

True if a descriptor with the specified ID exists; otherwise, false.

RemoveAllDescriptorsAsync(TimeSpan?, CancellationToken)

Removes all descriptors from this characteristic.

ValueTask RemoveAllDescriptorsAsync(TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

timeout TimeSpan?

The timeout for this operation.

cancellationToken CancellationToken

A cancellation token to cancel this operation.

Returns

ValueTask

A task that represents the asynchronous operation.

RemoveDescriptorAsync(IBluetoothLocalDescriptor, TimeSpan?, CancellationToken)

Removes a descriptor from this characteristic.

ValueTask RemoveDescriptorAsync(IBluetoothLocalDescriptor localDescriptor, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

localDescriptor IBluetoothLocalDescriptor

The descriptor to remove.

timeout TimeSpan?

The timeout for this operation.

cancellationToken CancellationToken

A cancellation token to cancel this operation.

Returns

ValueTask

A task that represents the asynchronous operation.

RemoveDescriptorAsync(Guid, TimeSpan?, CancellationToken)

Removes a descriptor from this characteristic.

ValueTask RemoveDescriptorAsync(Guid id, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

id Guid

The ID of the descriptor to remove.

timeout TimeSpan?

The timeout for this operation.

cancellationToken CancellationToken

A cancellation token to cancel this operation.

Returns

ValueTask

A task that represents the asynchronous operation.

UpdateValueAsync(ReadOnlyMemory<byte>, bool, TimeSpan?, CancellationToken)

Updates the value of a hosted characteristic and optionally notifies/indicates subscribed clients.

ValueTask UpdateValueAsync(ReadOnlyMemory<byte> value, bool notifyClients = true, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

value ReadOnlyMemory<byte>

The new value.

notifyClients bool

Whether to notify subscribed clients of the value change.

timeout TimeSpan?

The timeout for this operation

cancellationToken CancellationToken

A cancellation token to cancel this operation.

Returns

ValueTask

A task that represents the asynchronous operation.

Events

ClientSubscribed

Event raised when a client device subscribes to this characteristic.

event EventHandler<CharacteristicSubscriptionChangedEventArgs>? ClientSubscribed

Event Type

EventHandler<CharacteristicSubscriptionChangedEventArgs>

ClientUnsubscribed

Event raised when a client device unsubscribes from this characteristic.

event EventHandler<CharacteristicSubscriptionChangedEventArgs>? ClientUnsubscribed

Event Type

EventHandler<CharacteristicSubscriptionChangedEventArgs>

ReadRequested

Event raised when a client device requests to read this characteristic.

event EventHandler<CharacteristicReadRequestEventArgs>? ReadRequested

Event Type

EventHandler<CharacteristicReadRequestEventArgs>

WriteRequested

Event raised when a client device requests to write to this characteristic.

event EventHandler<CharacteristicWriteRequestEventArgs>? WriteRequested

Event Type

EventHandler<CharacteristicWriteRequestEventArgs>