Service implementation for Matter commissioning which facilitates communication between
your application and Google Play Services. This
CommissioningService
must be returned by an exported Service
, and that
service specified in the
CommissioningRequest
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()
)
}
}
CommissioningCompleteMetadata
, that token will be passed back to you in the
activity result via
CommissioningResult.getToken()
.
Nested Class Summary
class | CommissioningService.Builder | A builder to create an implementation of
CommissioningService . |
|
interface | CommissioningService.Callback | Callback interface to be notified of requests coming from Google Play Services to your application. | |
@interface | CommissioningService.CommissioningError | Enumeration of valid error code values for
CommissioningService.sendCommissioningError(int) |
Public Method Summary
abstract IBinder | |
abstract Task<Void> |
sendCommissioningComplete(CommissioningCompleteMetadata
metadata)
Asynchronously sends a response to Google Play Services indicating that you
have completed commissioning of a device supplied by
CommissioningService.Callback.onCommissioningRequested(CommissioningRequestMetadata)
|
abstract Task<Void> |
sendCommissioningError(int errorCode)
Asynchronously sends a response to Google Play Services indicating that you
could not complete commissioning of a device supplied by
CommissioningService.Callback.onCommissioningRequested(CommissioningRequestMetadata)
|
Public Methods
public abstract Task<Void> sendCommissioningComplete (CommissioningCompleteMetadata metadata)
Asynchronously sends a response to Google Play Services indicating that you have
completed commissioning of a device supplied by
CommissioningService.Callback.onCommissioningRequested(CommissioningRequestMetadata)
Parameters
metadata | additional metadata to send to complete the commissioning flow |
---|
Returns
- a task that will be completed when the response has been delivered
public abstract Task<Void> sendCommissioningError (int errorCode)
Asynchronously sends a response to Google Play Services indicating that you could
not complete commissioning of a device supplied by
CommissioningService.Callback.onCommissioningRequested(CommissioningRequestMetadata)
Parameters
errorCode | an error code from
CommissioningService.CommissioningError indicating the cause of the
failure |
---|
Returns
- a task that will be completed when the response has been delivered