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
Name
Gets the name of the characteristic.
string Name { get; }
Property Value
Permissions
The permissions of the characteristic.
BluetoothCharacteristicPermissions Permissions { get; init; }
Property Value
Properties
Gets the GATT properties supported by this characteristic (Read/Write/Notify/Indicate, etc.).
BluetoothCharacteristicProperties Properties { get; init; }
Property Value
Service
Gets the Bluetooth service hosting this characteristic.
IBluetoothLocalService Service { get; }
Property Value
SubscribedDevices
Gets the list of client devices that are currently subscribed to notifications/indications from this characteristic.
IReadOnlyList<IBluetoothConnectedDevice> SubscribedDevices { get; }
Property Value
Value
Gets the value of the characteristic as a read-only memory segment. Useful for asynchronous operations.
ReadOnlyMemory<byte> Value { get; }
Property Value
ValueSpan
Gets the value of the characteristic as a read-only span. Useful for high-performance scenarios.
ReadOnlySpan<byte> ValueSpan { get; }
Property Value
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
idGuidThe ID of the descriptor to add.
namestringAn optional name for the descriptor. If not provided, a default name may be assigned based on the ID or other heuristics.
timeoutTimeSpan?The timeout for this operation.
cancellationTokenCancellationTokenA 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
filterFunc<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
idGuidThe 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
filterFunc<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
idGuidThe 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
filterFunc<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
filterFunc<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
idGuidThe 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
timeoutTimeSpan?The timeout for this operation.
cancellationTokenCancellationTokenA 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
localDescriptorIBluetoothLocalDescriptorThe descriptor to remove.
timeoutTimeSpan?The timeout for this operation.
cancellationTokenCancellationTokenA 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
idGuidThe ID of the descriptor to remove.
timeoutTimeSpan?The timeout for this operation.
cancellationTokenCancellationTokenA 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
valueReadOnlyMemory<byte>The new value.
notifyClientsboolWhether to notify subscribed clients of the value change.
timeoutTimeSpan?The timeout for this operation
cancellationTokenCancellationTokenA 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
ClientUnsubscribed
Event raised when a client device unsubscribes from this characteristic.
event EventHandler<CharacteristicSubscriptionChangedEventArgs>? ClientUnsubscribed
Event Type
ReadRequested
Event raised when a client device requests to read this characteristic.
event EventHandler<CharacteristicReadRequestEventArgs>? ReadRequested
Event Type
WriteRequested
Event raised when a client device requests to write to this characteristic.
event EventHandler<CharacteristicWriteRequestEventArgs>? WriteRequested