CommissioningService

interface CommissioningService


Service implementation for Matter commissioning which facilitates communication between your application and Google Play Services. This CommissioningService must be returned by an exported android.app.Service, and that service specified in the in order to commission a device into your fabric.

An example implementation may look like:

class MatterCommissioningService : Service(), CommissioningService.Callback {
  private val commissioningServiceDelegate =
    CommissioningService.Builder(this)
      .setCallback(this)
      .build()

  override fun onBind(intent: Intent) = commissioningServiceDelegate.asBinder()

  override fun onCommissioningRequested(metadata: CommissioningRequestMetadata) {
    // perform commissioning

    commissioningServiceDelegate
      .sendCommissioningComplete(
        CommissioningCompleteMetadata.builder()
          .setToken(myInternalDeviceIdentifierString)
          .build()
      )
  }
}
If a token is specified in CommissioningCompleteMetadata, that token will be passed back to you in the activity result via getToken.

Summary

Nested types

A builder to create an implementation of CommissioningService.

Callback interface to be notified of requests coming from Google Play Services to your application.

@Retention(value = RetentionPolicy.SOURCE)
@IntDef(value = [CommissioningError.OTHER, CommissioningError.DEVICE_UNREACHABLE, CommissioningError.ATTESTATION_FAILED])
annotation CommissioningService.CommissioningError

Enumeration of valid error code values for sendCommissioningError

Public functions

IBinder!

Returns the IBinder to return from your service.

Task<Void!>!

Asynchronously sends a response to Google Play Services indicating that you have completed commissioning of a device supplied by onCommissioningRequested

Task<Void!>!

Asynchronously sends a response to Google Play Services indicating that you could not complete commissioning of a device supplied by onCommissioningRequested

Public functions

asBinder

fun asBinder(): IBinder!

Returns the IBinder to return from your service.

sendCommissioningComplete

fun sendCommissioningComplete(metadata: CommissioningCompleteMetadata!): Task<Void!>!

Asynchronously sends a response to Google Play Services indicating that you have completed commissioning of a device supplied by onCommissioningRequested

Parameters
metadata: CommissioningCompleteMetadata!

additional metadata to send to complete the commissioning flow

Returns
Task<Void!>!

a task that will be completed when the response has been delivered

sendCommissioningError

fun sendCommissioningError(
    @CommissioningService.CommissioningError errorCode: Int
): Task<Void!>!

Asynchronously sends a response to Google Play Services indicating that you could not complete commissioning of a device supplied by onCommissioningRequested

Parameters
@CommissioningService.CommissioningError errorCode: Int

an error code from CommissioningError indicating the cause of the failure

Returns
Task<Void!>!

a task that will be completed when the response has been delivered