Table of Contents

Interface IBluetoothLocalService

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

Represents a service in the context of bluetooth broadcasting.

public interface IBluetoothLocalService : INotifyPropertyChanged, IAsyncDisposable
Inherited Members

Properties

Broadcaster

Gets the Bluetooth broadcaster hosting this service.

IBluetoothBroadcaster Broadcaster { get; }

Property Value

IBluetoothBroadcaster

Id

Gets the service UUID.

Guid Id { get; }

Property Value

Guid

IsPrimary

Gets a value indicating whether this service is a primary service.

bool IsPrimary { get; }

Property Value

bool

Name

Gets the name of the service.

string Name { get; }

Property Value

string

Methods

CreateCharacteristicAsync(Guid, BluetoothCharacteristicProperties, BluetoothCharacteristicPermissions, string?, TimeSpan?, CancellationToken)

Adds a GATT characteristic to be hosted by the broadcaster.

ValueTask<IBluetoothLocalCharacteristic> CreateCharacteristicAsync(Guid id, BluetoothCharacteristicProperties properties, BluetoothCharacteristicPermissions permissions, string? name = null, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

id Guid

The UUID of the characteristic to add.

properties BluetoothCharacteristicProperties

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

permissions BluetoothCharacteristicPermissions

The permissions of the characteristic.

name string

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

timeout TimeSpan?

The timeout for this operation

cancellationToken CancellationToken

A cancellation token to cancel this operation.

Returns

ValueTask<IBluetoothLocalCharacteristic>

The added characteristic.

GetCharacteristic(Func<IBluetoothLocalCharacteristic, bool>)

Gets a hosted GATT characteristic that matches the specified filter.

IBluetoothLocalCharacteristic GetCharacteristic(Func<IBluetoothLocalCharacteristic, bool> filter)

Parameters

filter Func<IBluetoothLocalCharacteristic, bool>

A function to filter characteristics. Should return true for the desired characteristic.

Returns

IBluetoothLocalCharacteristic

The matching characteristic.

Exceptions

CharacteristicNotFoundException

Thrown if no characteristic matches the specified filter.

MultipleCharacteristicsFoundException

Thrown if multiple characteristics match the specified filter.

GetCharacteristic(Guid)

Gets a hosted GATT characteristic by its UUID.

IBluetoothLocalCharacteristic GetCharacteristic(Guid id)

Parameters

id Guid

The UUID of the characteristic to retrieve.

Returns

IBluetoothLocalCharacteristic

The matching characteristic.

Exceptions

CharacteristicNotFoundException

Thrown if no characteristic matches the specified filter.

MultipleCharacteristicsFoundException

Thrown if multiple characteristics match the specified filter.

GetCharacteristicOrDefault(Func<IBluetoothLocalCharacteristic, bool>)

Gets a hosted GATT characteristic that matches the specified filter.

IBluetoothLocalCharacteristic? GetCharacteristicOrDefault(Func<IBluetoothLocalCharacteristic, bool> filter)

Parameters

filter Func<IBluetoothLocalCharacteristic, bool>

A function to filter characteristics. Should return true for the desired characteristic.

Returns

IBluetoothLocalCharacteristic

The matching characteristic, or null if not found.

GetCharacteristicOrDefault(Guid)

Gets a hosted GATT characteristic by its UUID.

IBluetoothLocalCharacteristic? GetCharacteristicOrDefault(Guid id)

Parameters

id Guid

The UUID of the characteristic to retrieve.

Returns

IBluetoothLocalCharacteristic

The matching characteristic, or null if not found.

GetCharacteristics(Func<IBluetoothLocalCharacteristic, bool>?)

Gets all hosted GATT characteristics.

IEnumerable<IBluetoothLocalCharacteristic> GetCharacteristics(Func<IBluetoothLocalCharacteristic, bool>? filter = null)

Parameters

filter Func<IBluetoothLocalCharacteristic, bool>

An optional filter to apply to the characteristics.

Returns

IEnumerable<IBluetoothLocalCharacteristic>

A collection of all hosted characteristics.

HasCharacteristic(Func<IBluetoothLocalCharacteristic, bool>)

Checks if a hosted GATT characteristic that matches the specified filter exists.

bool HasCharacteristic(Func<IBluetoothLocalCharacteristic, bool> filter)

Parameters

filter Func<IBluetoothLocalCharacteristic, bool>

A function to filter characteristics. Should return true for the desired characteristic.

Returns

bool

True if a matching characteristic exists, false otherwise.

HasCharacteristic(Guid)

Checks if a hosted GATT characteristic with the specified UUID exists.

bool HasCharacteristic(Guid id)

Parameters

id Guid

The UUID of the characteristic to check for.

Returns

bool

True if a matching characteristic exists, false otherwise.

RemoveAllCharacteristicsAsync(TimeSpan?, CancellationToken)

Removes all hosted characteristics from the broadcaster.

ValueTask RemoveAllCharacteristicsAsync(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.

RemoveCharacteristicAsync(IBluetoothLocalCharacteristic, TimeSpan?, CancellationToken)

Removes a hosted GATT characteristic from the broadcaster.

ValueTask RemoveCharacteristicAsync(IBluetoothLocalCharacteristic localCharacteristic, TimeSpan? timeout = null, CancellationToken cancellationToken = default)

Parameters

localCharacteristic IBluetoothLocalCharacteristic

The characteristic 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.

RemoveCharacteristicAsync(Guid, TimeSpan?, CancellationToken)

Removes a hosted GATT characteristic from the broadcaster.

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

Parameters

id Guid

The UUID of the characteristic 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.