MultiService

abstract class MultiService(requiredServiceUuids: List<Uuid>, optionalServiceUuids: List<Uuid> = emptyList(), name: String? = null) : Profile

A class representing a multiservice GATT profile.

This is intended for profiles that have multiple GATT services, i.e. Proximity Profile.

Note, the prepare method may be called with a list of services containing multiple instances of the same service if returned by the service discovery. For example, if a device has multiple batteries, it may expose their level with a Battery Service for each of them.

See Profile for a full worked example (ProximityProfile).

Parameters

requiredServiceUuids

A list of UUIDs of required profile GATT services.

optionalServiceUuids

A list of UUIDs of optional profile GATT services.

name

The name of the profile. This is for convenience, used only in logging.

Constructors

Link copied to clipboard
constructor(requiredServiceUuids: List<Uuid>, optionalServiceUuids: List<Uuid> = emptyList(), name: String? = null)

Properties

Link copied to clipboard
val name: String?

The name of the profile. This is for convenience, used only in logging.

Functions

Link copied to clipboard
protected open suspend fun failed(peripheral: Peripheral<*, *>, reason: RemoteServices.Failed.Reason)

Notifies the profile implementation that service discovery has failed.

Link copied to clipboard
protected abstract suspend fun CoroutineScope.initialize(peripheral: Peripheral<*, *>)

This method should initialize the profile.

Link copied to clipboard
protected abstract fun prepare(peripheral: Peripheral<*, *>, services: List<RemoteService>)

Validates and prepares the services to be used in initialize.

Link copied to clipboard
protected open suspend fun unsupported(peripheral: Peripheral<*, *>)

Notifies the profile implementation, that the peripheral does not support the required profile services.