At Google, our goal is to provide intuitive,
easy-to-integrate SDK for the Matter Google Play services module,
for device commissioning and sharing.
We aim to not only simplify development,
but also to provide a consistent, standardized device setup flow
and user experience.
Hi, my name is James Romo on the Google Nest Partner Engineering team.
And, in this talk, I’m going to discuss “Mobile Development for Matter.”
Mobile devices are a central interaction point
with smart home devices,
where users can set up and control devices with their favorite apps.
We want to make mobile development fast and easy
with Matter on Android and are previewing our Matter APIs
in Google Play services today.
Fabric is a shared domain of trust among devices in the home network
that enables them to communicate with each other.
Devices may have one or more Fabrics that correspond to a platform, app,
or group of devices interacting together.
This shared domain of trust is established via a common set of cryptographic keys.
First, I will discuss how to commission devices.
Let's take a look at the setup flow for a new Matter device in your Android app.
The initial step is for your app to initiate the “add new device” flow,
which will redirect to the Google Play services commissioning flow,
and starts by prompting the user
to scan the device QR code, or a setup code.
If you already have this information,
it can be supplied as part of the CommissioningRequest data.
In which case, this step will be skipped.
Once scanned, the user will be prompted
to connect the device to the user’s Google account.
Google Play services will connect the device to Wi-Fi,
ethernet, and/or Thread networks, as applicable.
After the device successfully connects,
the user will be prompted to select the device name,
and optionally, the location in their home.
Once the fields are submitted,
the user will be redirected from the Google Play services provided UI
back to your app.
Let’s take a look at the full commissioning flow
we just walked through,
which encompasses the broadcasting of the device
through the user setting, the device name, and room.
As you can see, there are numerous interactions between your app,
Google Play services and the Matter device.
In this next section, I’ll walk through the flow with each step identified
with a box in the preview flows shown above.
The initial step involves commissioning the device
using the CommissioningClient,
which can be obtained from the Matter entry point.
This can be retrieved either using a Context or Activity.
If the device being searched for is known,
it can be specified via the DeviceInfo in the CommissioningRequest,
and it will be set up during the commissioning process.
Alternatively, if you already have proof of possession of the device,
such as a manually-entered passcode or QR code,
you can provide this in the CommissioningRequest
to target a specific device,
and bypass the need to obtain this info from the user during commissioning.
To commission your own Fabric,
you must provide an export implementation of AbstractCommissioningService,
which will be notified when the device is ready
to have your operational certificates installed on the device.
The next steps involve establishing proof of possession
using a QR code, or a manually-entered code,
commissioning the device into Google Fabric,
and connecting to the operational network.
These steps are color-coded and match up to the preview flows shown above.
Everything will be provided out of the box by the Play Services flow,
with no need for your app to do anything.
After connecting to the network,
you’ll be able to commission your device into your Fabric.
The onCommissioningRequested method in your implementation
of the AbstractCommissioningService will be invoked,
and a manual pairing code will be provided to you,
so that you can commission the device with your own Fabric credentials.
After you’ve completed your desired commissioning steps
and have issued a CommissioningComplete command
to your commissioned device,
you must call sendCommissioningComplete() to indicate success.
Alternatively, if something went wrong during the process,
you can call sendCommissioningFailure() to indicate the cause.
In this sendCommissioningComplete() response,
you can also supply a list of room names and a suggested name for the device.
Both are optional and will be presented to your user to choose from or modify.
The chosen name will be written to the Basic Information Cluster
as the UserLabel, and the selected name and room, if any,
will be returned to the CommissioningResult.
Finally, the last step involves redirecting back to your app
with the CommissioningResult,
containing the user-selected room and device name.
This CommissioningResult can be obtained from the IntentSender result
via the CommissioningResult.fromIntent().
Next, I'll discuss Operational Discovery.
Operational Discovery is an API,
which allows an application to register to be notified
of any commissioned Matter devices that are discovered on the network via mDNS.
An example could be notifying when users reconnect
to Wi-Fi networks on their phones so UI can be refreshed.
Using the DiscoveryClient interface,
you’re able to request or remove DeviceUpdateListeners,
which contain callback methods
that are notified about operational device updates.
requestOperationalDeviceUpdates
allows your app to request to receive updates,
and initial state for operational Matter devices.
In your request, you can specify a particular set of service instance names
so you can limit the number of updates your app receives.
The listener’ll be notified of the initial state
and any changes to nearby operational devices,
as they are discovered or changed.
After finishing, you can remove a previously registered listener
using removeOperationalDeviceUpdates.
Next, I’ll discuss Matter device sharing for Android apps.
Sharing a device involves opening a temporary commissioning flow on the device
and either picking the app you want to use or using a provided passcode
that can be used to open a connection to the device.
The process is displayed in the preview flows as shown here.
It starts in your app, followed by this sharing screen,
which should look familiar if you've used the Android sharing screen.
This will allow users to select from any other Matter commissioning app on the phone,
which registers an intent filter for commissioning.
Alternatively, the user will be able to share the manual pairing passcode
via plain text, or QR code, if desired.
The following diagram steps through this process
with the preview flows at the top showing the current place in the flow.
The current admin, in this case, is the administrator of the Fabric.
Using the shareDevice function of CommissioningClient,
you're able to share a Matter device
which you administer for use within another Matter fabric or ecosystem.
You must first open a commissioning window on the device
and provide the details,
including the manual pairing code and window duration
in your ShareDeviceRequest.
This request will succeed if the user chooses a sharing destination.
If the user cancels or the commissioning window times out
at the specified duration without choosing a destination,
you’ll receive a RESULT_CANCELED status and should revoke the commissioning window.
To register as a commissioner, use the following intent filter in your app.
Then when a sharing action is initiated by the user,
your app will be included in the list
unless it is an app initiating the sharing request.
The final step involves sending intent with ACTION_COMMISSION_DEVICE
to the chosen commissioner,
containing a set of intent extras, detailing the device that was shared.
The following diagram and table show all the keys that can be provided
via the ACTION_COMMISSION_DEVICE when commissioning a device.
As a commissioner receiving such an intent, you can use this information
to construct a new CommissioningRequest and use this with the commissionDevice() API.
With that, we have the whole picture for sharing Matter devices on Android,
as shown in the full diagram, complete with all the steps we discussed.
That concludes “Mobile Development for Matter” presentation.
Thanks for joining us.
Be sure to stay current on the latest releases
to incorporate Play Services into your app.