|
| 1 | +# Matter Linux Fabric Sync Example |
| 2 | + |
| 3 | +An example application to implement the Fabric Synchronization feature and |
| 4 | +demonstrates the end-to-end Fabric Synchronization feature using dynamic |
| 5 | +endpoints. |
| 6 | + |
| 7 | +Fabric Synchronization feature will facilitate the commissioning of end devices |
| 8 | +from one fabric to another without requiring user intervention for every end |
| 9 | +device. It defines mechanisms that can be used by multiple |
| 10 | +ecosystems/controllers to communicate with one another to simplify the |
| 11 | +experience for users. |
| 12 | + |
| 13 | +This doc is tested on **Ubuntu 22.04 LTS (aarch64)** |
| 14 | + |
| 15 | +<hr> |
| 16 | + |
| 17 | +- [Matter Linux Fabric Sync Example](#matter-linux-fabric-sync-example) |
| 18 | + - [Theory of Operation](#theory-of-operation) |
| 19 | + - [Building](#building) |
| 20 | + - [Running the Complete Example on Ubuntu](#running-the-complete-example-on-ubuntu) |
| 21 | + |
| 22 | +<hr> |
| 23 | + |
| 24 | +## Theory of Operation |
| 25 | + |
| 26 | +### Dynamic Endpoints |
| 27 | + |
| 28 | +The Fabric-Sync Example makes use of Dynamic Endpoints. Current SDK support is |
| 29 | +limited for dynamic endpoints, since endpoints are typically defined (along with |
| 30 | +the clusters and attributes they contain) in a .zap file which then generates |
| 31 | +code and static structures to define the endpoints. |
| 32 | + |
| 33 | +To support endpoints that are not statically defined, the ZCL attribute storage |
| 34 | +mechanisms will hold additional endpoint information for `NUM_DYNAMIC_ENDPOINTS` |
| 35 | +additional endpoints. These additional endpoint structures must be defined by |
| 36 | +the application and can change at runtime. |
| 37 | + |
| 38 | +To facilitate the creation of these endpoint structures, several macros are |
| 39 | +defined: |
| 40 | + |
| 41 | +`DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN(attrListName)` |
| 42 | +`DECLARE_DYNAMIC_ATTRIBUTE(attId, attType, attSizeBytes, attrMask)` |
| 43 | +`DECLARE_DYNAMIC_ATTRIBUTE_LIST_END(clusterRevision)` |
| 44 | + |
| 45 | +- These three macros are used to declare a list of attributes for use within a |
| 46 | + cluster. The declaration must begin with the |
| 47 | + `DECLARE_DYNAMIC_ATTRIBUTE_LIST_BEGIN` macro which will define the name of |
| 48 | + the allocated attribute structure. Each attribute is then added by the |
| 49 | + `DECLARE_DYNAMIC_ATTRIBUTE` macro. Finally, |
| 50 | + `DECLARE_DYNAMIC_ATTRIBUTE_LIST_END` macro should be used to close the |
| 51 | + definition. |
| 52 | + |
| 53 | +- All attributes defined with these macros will be configured as |
| 54 | + `ATTRIBUTE_MASK_EXTERNAL_STORAGE` in the ZCL database and therefore will |
| 55 | + rely on the application to maintain storage for the attribute. Consequently, |
| 56 | + reads or writes to these attributes must be handled within the application |
| 57 | + by the `emberAfExternalAttributeWriteCallback` and |
| 58 | + `emberAfExternalAttributeReadCallback` functions. See the bridge |
| 59 | + application's `main.cpp` for an example of this implementation. |
| 60 | + |
| 61 | +`DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN(clusterListName)` |
| 62 | +`DECLARE_DYNAMIC_CLUSTER(clusterId, clusterAttrs, role, incomingCommands, outgoingCommands)` |
| 63 | +`DECLARE_DYNAMIC_CLUSTER_LIST_END` |
| 64 | + |
| 65 | +- These three macros are used to declare a list of clusters for use within a |
| 66 | + endpoint. The declaration must begin with the |
| 67 | + `DECLARE_DYNAMIC_CLUSTER_LIST_BEGIN` macro which will define the name of the |
| 68 | + allocated cluster structure. Each cluster is then added by the |
| 69 | + `DECLARE_DYNAMIC_CLUSTER` macro referencing attribute list previously |
| 70 | + defined by the `DECLARE_DYNAMIC_ATTRIBUTE...` macros and the lists of |
| 71 | + incoming/outgoing commands terminated by kInvalidCommandId (or nullptr if |
| 72 | + there aren't any commands in the list). Finally, |
| 73 | + `DECLARE_DYNAMIC_CLUSTER_LIST_END` macro should be used to close the |
| 74 | + definition. |
| 75 | + |
| 76 | +`DECLARE_DYNAMIC_ENDPOINT(endpointName, clusterList)` |
| 77 | + |
| 78 | +- This macro is used to declare an endpoint and its associated cluster list, |
| 79 | + which must be previously defined by the `DECLARE_DYNAMIC_CLUSTER...` macros. |
| 80 | + |
| 81 | +## Building |
| 82 | + |
| 83 | + ### For Linux host example: |
| 84 | + |
| 85 | + ``` |
| 86 | + ./scripts/examples/gn_build_example.sh examples/fabric-sync out/debug/standalone |
| 87 | + ``` |
| 88 | + |
| 89 | + ### For Raspberry Pi 4 example: |
| 90 | + |
| 91 | + TODO |
| 92 | + |
| 93 | +## Running the Complete Example on Ubuntu |
| 94 | + |
| 95 | +- Building |
| 96 | + |
| 97 | + Follow [Building](#building) section of this document. |
| 98 | + |
| 99 | +- Run Linux Fabric Sync Example App |
| 100 | + |
| 101 | + ```sh |
| 102 | + cd ~/connectedhomeip/ |
| 103 | + sudo out/debug/fabric-sync |
| 104 | + ``` |
0 commit comments