Prepare for Integration with Matter Device

Last Updated on : 2023-07-19 09:09:26download

Due to the characteristics of a Matter device, all its capabilities are implemented based on Matter fabrics. Before a Matter device can be paired, controlled, or managed, you must make API requests to configure basic information about the Matter device. This configuration must be finished before any Matter services are implemented.

A fabric is a group of networked devices (also known as nodes) that share the same security domain. This enables secure communications among these nodes within the fabric. Nodes in the same fabric share the same Certificate Authority’s (CA) top-level certificate (Root of Trust) and within the context of the CA, a unique 64-bit identifier named Fabric ID.

Requirements

  • Prerequisites

    Before you start, the steps in Fast Integration with Smart Life App SDK must be finished.

  • Scope of application

    All Matter devices are supported.

  • Requirements for devices

    • OS: Android M (6.0, API level 23 or later).
    • Required permissions: Bluetooth, location, and Wi-Fi.

    If you require UI BizBundles, the version of Smart Life App SDK must be the same as that of the UI BizBundles to ensure stable pairing and control of devices.

Sequence diagram

The following figure shows the sequence in which basic Matter information is configured.

UserAppSDKInitially load home or switch between homesLoad information about homeReturn information about homeRequest loading list of devicesReturn list of devicesHandle Matter capabilitiesPrepare information about fabricFabric information loadedPrepare information about devicesDevice information preparedUse Matter capabilitiesUserAppSDK

Prepare information about fabric

Information about Matter is bound with homes. Therefore, at the end of the operation of switching between homes or initially loading a home, call - initFabric to get information about the fabric that is bound with the home.

API description

void initFabric( Context context, long gid, IThingDataCallback<OpenFabricInfo> callback);

Parameters

Parameter Description
Context The context.
gid The value of HomeID for the current home.
callback The callback.

Example

IThingMatterFabricManager fabricManager = ThingHomeSdk.getFabricManager();
fabricManager.initFabric(getContext(), spaceId, new IThingDataCallback<OpenFabricInfo>() {
     @Override
     public void onSuccess(OpenFabricInfo result) {

    }

    @Override
    public void onError(String errorCode, String errorMessage) {

    }
});

Prepare information about devices

Different from other types of devices, certain information about Matter devices must be prepared in advance. For this purpose, at the end of loading the list of devices in a home and fabric information, call getDevicesFabricNodes to handle Matter devices for the specified home.

API description

void getDevicesFabricNodes(Set<String> devIds, IThingDataCallback<ArrayList<DeviceNodeBean>> listener);

Parameters

Parameter Description
devIds The list of device IDs.

Example

List<DeviceBean> deviceList = homeBean.getDeviceList();
Set<String> devIds = new HashSet<>();
devIds.add(deviceBean.getDevId());
fabricManager.getDevicesFabricNodes(devIds, new IThingDataCallback<ArrayList<DeviceNodeBean>>() {
@Override
public void onSuccess(ArrayList<DeviceNodeBean> result) {

}

@Override
public void onError(String errorCode, String errorMessage) {

}
});