From e8a785576f11923c581e3dbc4a9ef2cd33185dd0 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Wed, 14 Aug 2024 10:35:44 -0700 Subject: [PATCH 1/5] [Fabric-Sync] Symplify and update the fabric sync guide --- docs/guides/fabric_synchronization_guide.md | 106 ++++++++++++------ .../commands/fabric-sync/Commands.h | 1 - .../device_manager/DeviceManager.cpp | 3 +- .../fabric-admin/scripts/run_fabric_sink.sh | 78 ------------- ...un_fabric_source.sh => run_fabric_sync.sh} | 14 +-- ...p_fabric_source.sh => stop_fabric_sync.sh} | 0 6 files changed, 81 insertions(+), 121 deletions(-) delete mode 100755 examples/fabric-admin/scripts/run_fabric_sink.sh rename examples/fabric-admin/scripts/{run_fabric_source.sh => run_fabric_sync.sh} (85%) rename examples/fabric-admin/scripts/{stop_fabric_source.sh => stop_fabric_sync.sh} (100%) diff --git a/docs/guides/fabric_synchronization_guide.md b/docs/guides/fabric_synchronization_guide.md index 1b545ce36ead27..b3f48852667b1e 100644 --- a/docs/guides/fabric_synchronization_guide.md +++ b/docs/guides/fabric_synchronization_guide.md @@ -2,7 +2,9 @@ - [Fabric Synchronization Guide](#fabric-synchronization-guide) - [Fabric Sync Example Applications](#fabric-sync-example-applications) - - [Run Fabric Sync Demo on RP4](#run-fabric-sync-demo-on-rp4) + - [Bootstrap Fabric Sync Demo on Linux](#bootstrap-fabric-sync-demo-on-linux) + - [Bootstrap Fabric Sync Demo on RP4](#bootstrap-fabric-sync-demo-on-rp4) + - [Run Fabric Sync Demo](#run-fabric-sync-demo) ## Fabric Sync Example Applications @@ -38,27 +40,29 @@ enables a seamless and efficient synchronization process. [Fabric-Bridge](https://github.com/project-chip/connectedhomeip/tree/master/examples/fabric-bridge-app/linux/README.md) -## Run Fabric Sync Demo on RP4 +## Bootstrap Fabric Sync Demo on Linux -### Setup Fabric Source +### Start Fabric Synchronization on Ecosystem 1 -Connect to the Fabric Source server: +Run the Fabric Synchronization script: ``` -ssh ubuntu@xxx.xxx.xxx.xxx +./examples/fabric-admin/scripts/run_fabric_sync.sh ``` -Password: +### Start Fabric Synchronization on Ecosystem 2 -Run the Fabric Source script: +Run the Fabric Synchronization script: ``` -./run_fabric_source.sh +./examples/fabric-admin/scripts/run_fabric_sync.sh ``` -### Setup Fabric Sink +## Bootstrap Fabric Sync Demo on RP4 -Connect to the Fabric Sink server: +### Start Fabric Synchronization on Ecosystem 1 + +Connect to the Ecosystem 1 server: ``` ssh ubuntu@xxx.xxx.xxx.xxx @@ -66,29 +70,41 @@ ssh ubuntu@xxx.xxx.xxx.xxx Password: -Run the Fabric Sink script: +Run the Fabric Synchronization script: ``` -./run_fabric_sink.sh +./run_fabric_sync.sh ``` -### Fabric Sync Setup +### Start Fabric Synchronization on Ecosystem 2 + +Connect to the Ecosystem 2 server: + +``` +ssh ubuntu@xxx.xxx.xxx.xxx +``` -Enable Fabric Auto Sync: +Password: -In Fabric-Sync console: +Run the Fabric Synchronization script: ``` -fabricsync enable-auto-sync 1 +./run_fabric_sync.sh ``` -Pair the Fabric-Source bridge to Fabric-Sync with node ID 1: +## Run Fabric Sync Demo + +### Fabric Sync Setup + +In Ecosystem 1 Fabric-Admin console: + +Pair the Ecosystem 2 bridge to Ecosystem 1 with node ID 2: ``` -fabricsync add-bridge 1 +fabricsync add-bridge 2 ``` -### Pair Light Example to Fabric-Source +### Pair Light Example to Ecosystem 2 Since Fabric-Bridge also functions as a Matter server, running it alongside the Light Example app on the same machine would cause conflicts. Therefore, you need @@ -114,26 +130,46 @@ Pair the Light Example with node ID 3 using its payload number: pairing already-discovered 3 20202021 5540 ``` -After the Light Example is successfully paired in Fabric-Source, it will be -synced to Fabric-Sink with a new assigned node ID. +After the device is successfully added, you will observe the following on Ecosystem 2 +with the newly assigned Node ID: + +``` +>>> New device with Node ID: 0x3 has been successfully added. +``` + +Additionally, you should also get notified an new device is added on the Ecosystem 2 from +the Ecosystem 1: + +``` +>>> A new devie is added on Endpoint 3. +``` + +### Synchronize Light Example to Ecosystem 1 + +After the Light Example is successfully paired in Ecosystem 2, we can start to synchronize +the light device to Ecosystem 1 using the new assigned dynamic endpointid on Ecosystem 2. + +``` +fabricsync sync-device +``` Toggle the Light Example: -From Fabric-Source: +From Ecosystem 1: ``` onoff on 1 onoff off 1 ``` -From Fabric-Sink: (Use the node ID assigned) +From Ecosystem 2: (Use the node ID assigned) ``` onoff on x 1 onoff off x 1 ``` -### Remove Light Example from Fabric-Source +### Remove Light Example from Ecosystem Unpair the Light Example: @@ -141,9 +177,6 @@ Unpair the Light Example: pairing unpair ``` -After the Light Example is successfully unpaired from Fabric-Source, it will -also be removed from the Fabric-Sink. - ### Pair Commercial Switch to Fabric-Source Pair the switch using its payload number: @@ -154,26 +187,32 @@ In Fabric-Source console: pairing code-wifi ``` -After the switch is successfully paired in Fabric-Source, it will be synced to -Fabric-Sink with a new assigned node ID. +### Synchronize Switch to Ecosystem 1 + +After the switch is successfully paired in Ecosystem 2, we can start to synchronize it +to Ecosystem 1 using the new assigned dynamic endpointid on Ecosystem 2.. + +``` +fabricsync sync-device +``` Toggle the switch: -From Fabric-Source: +From Ecosystem 1: ``` onoff on 1 onoff off 1 ``` -From Fabric-Sink: (Use the node ID assigned) +From Ecosystem 2: (Use the node ID assigned) ``` onoff on 1 onoff off 1 ``` -### Remove Switch from Fabric-Source +### Remove Switch from Ecosystem Unpair the switch: @@ -181,5 +220,4 @@ Unpair the switch: pairing unpair ``` -After the switch is successfully unpaired from Fabric-Source, it will also be -removed from the Fabric-Sink. + diff --git a/examples/fabric-admin/commands/fabric-sync/Commands.h b/examples/fabric-admin/commands/fabric-sync/Commands.h index 94de1d31d8ba09..c1cedd0727b220 100644 --- a/examples/fabric-admin/commands/fabric-sync/Commands.h +++ b/examples/fabric-admin/commands/fabric-sync/Commands.h @@ -29,7 +29,6 @@ void registerCommandsFabricSync(Commands & commands, CredentialIssuerCommands * make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), }; commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for fabric synchronization."); diff --git a/examples/fabric-admin/device_manager/DeviceManager.cpp b/examples/fabric-admin/device_manager/DeviceManager.cpp index 4207378670f44e..7204e153d2807f 100644 --- a/examples/fabric-admin/device_manager/DeviceManager.cpp +++ b/examples/fabric-admin/device_manager/DeviceManager.cpp @@ -331,7 +331,8 @@ void DeviceManager::HandleAttributeData(const app::ConcreteDataAttributePath & p // Process added endpoints for (const auto & endpoint : addedEndpoints) { - ChipLogProgress(NotSpecified, "Endpoint added: %u", endpoint); + // print to console + fprintf(stderr, "A new devie is added on Endpoint: %u\n", endpoint); if (mAutoSyncEnabled) { diff --git a/examples/fabric-admin/scripts/run_fabric_sink.sh b/examples/fabric-admin/scripts/run_fabric_sink.sh deleted file mode 100755 index 3013965479268a..00000000000000 --- a/examples/fabric-admin/scripts/run_fabric_sink.sh +++ /dev/null @@ -1,78 +0,0 @@ -#!/bin/bash - -# Default paths -DEFAULT_CHOICES=( - "./fabric-admin" - "out/debug/standalone/fabric-admin" - "out/linux-x64-fabric-admin/fabric-admin" - "out/darwin-arm64-fabric-admin/fabric-admin" -) -FABRIC_ADMIN_LOG="/tmp/fabric_admin.log" -FABRIC_ADMIN_PATH="" - -# Function to find fabric-admin binary -find_fabric_admin() { - local choices=("$@") - for path in "${choices[@]}"; do - if [[ -e "$path" ]]; then - echo "$path" - return 0 - fi - done - return 1 -} - -# Parse arguments -VERBOSE=false -SPECIFIED_PATH="" - -for arg in "$@"; do - case $arg in - --verbose) - VERBOSE=true - ;; - --path=*) - SPECIFIED_PATH="${arg#*=}" - ;; - esac -done - -# Use specified path if provided -if [[ -n "$SPECIFIED_PATH" ]]; then - if [[ -e "$SPECIFIED_PATH" ]]; then - FABRIC_ADMIN_PATH="$SPECIFIED_PATH" - else - echo >&2 "Specified path does not exist: $SPECIFIED_PATH" - exit 1 - fi -else - FABRIC_ADMIN_PATH=$(find_fabric_admin "${DEFAULT_CHOICES[@]}") - if [[ $? -ne 0 ]]; then - echo >&2 "Could not find the fabric-admin binary" - exit 1 - fi -fi - -echo "PATH IS: $FABRIC_ADMIN_PATH" - -# Kill fabric-admin if it is running -echo "Checking for running fabric-admin process..." -fabric_admin_pid=$(pgrep -f "$FABRIC_ADMIN_PATH") -if [[ -n "$fabric_admin_pid" ]]; then - echo "Found fabric-admin with PID $fabric_admin_pid, attempting to kill..." - kill -9 "$fabric_admin_pid" - echo "Killed fabric-admin with PID $fabric_admin_pid" -fi - -# Remove /tmp/chip_* files and directories -echo "Removing /tmp/chip_* files and directories..." -sudo rm -rf /tmp/chip_* -echo "Removed /tmp/chip_* files and directories" - -# Start fabric-admin with or without log file path based on --verbose option -echo "Starting fabric-admin..." -if [ "$VERBOSE" = true ]; then - "$FABRIC_ADMIN_PATH" -else - "$FABRIC_ADMIN_PATH" --log-file-path "$FABRIC_ADMIN_LOG" -fi diff --git a/examples/fabric-admin/scripts/run_fabric_source.sh b/examples/fabric-admin/scripts/run_fabric_sync.sh similarity index 85% rename from examples/fabric-admin/scripts/run_fabric_source.sh rename to examples/fabric-admin/scripts/run_fabric_sync.sh index 95df7a135bb596..8c820d111c37c1 100755 --- a/examples/fabric-admin/scripts/run_fabric_source.sh +++ b/examples/fabric-admin/scripts/run_fabric_sync.sh @@ -86,19 +86,19 @@ fi echo "Admin path: $FABRIC_ADMIN_PATH" echo "Bridge path: $FABRIC_BRIDGE_APP_PATH" -# Determine the path to stop_fabric_source.sh based on the location of run_fabric_source.sh -RUN_FABRIC_SOURCE_PATH=$(find_binary "$SCRIPT_DIR/run_fabric_source.sh") +# Determine the path to stop_fabric_sync.sh based on the location of run_fabric_sync.sh +RUN_FABRIC_SOURCE_PATH=$(find_binary "$SCRIPT_DIR/run_fabric_sync.sh") if [[ $? -ne 0 ]]; then - echo >&2 "Could not find the run_fabric_source.sh script" + echo >&2 "Could not find the run_fabric_sync.sh script" exit 1 fi -STOP_FABRIC_SOURCE_PATH="${RUN_FABRIC_SOURCE_PATH/run_fabric_source/stop_fabric_source}" +STOP_FABRIC_SYNC_PATH="${RUN_FABRIC_SOURCE_PATH/run_fabric_sync/stop_fabric_sync}" # Stop any running instances and clean up -if [[ -e "$STOP_FABRIC_SOURCE_PATH" ]]; then - "$STOP_FABRIC_SOURCE_PATH" +if [[ -e "$STOP_FABRIC_SYNC_PATH" ]]; then + "$STOP_FABRIC_SYNC_PATH" else - echo >&2 "Could not find the stop_fabric_source.sh script" + echo >&2 "Could not find the stop_fabric_sync.sh script" exit 1 fi diff --git a/examples/fabric-admin/scripts/stop_fabric_source.sh b/examples/fabric-admin/scripts/stop_fabric_sync.sh similarity index 100% rename from examples/fabric-admin/scripts/stop_fabric_source.sh rename to examples/fabric-admin/scripts/stop_fabric_sync.sh From c85e02a3f692bf55dc025ea8b2aac9159083caf0 Mon Sep 17 00:00:00 2001 From: "Restyled.io" Date: Wed, 14 Aug 2024 18:44:43 +0000 Subject: [PATCH 2/5] Restyled by prettier-markdown --- docs/guides/fabric_synchronization_guide.md | 26 ++++++++++----------- 1 file changed, 13 insertions(+), 13 deletions(-) diff --git a/docs/guides/fabric_synchronization_guide.md b/docs/guides/fabric_synchronization_guide.md index b3f48852667b1e..22439249a2d943 100644 --- a/docs/guides/fabric_synchronization_guide.md +++ b/docs/guides/fabric_synchronization_guide.md @@ -4,7 +4,7 @@ - [Fabric Sync Example Applications](#fabric-sync-example-applications) - [Bootstrap Fabric Sync Demo on Linux](#bootstrap-fabric-sync-demo-on-linux) - [Bootstrap Fabric Sync Demo on RP4](#bootstrap-fabric-sync-demo-on-rp4) - - [Run Fabric Sync Demo](#run-fabric-sync-demo) + - [Run Fabric Sync Demo](#run-fabric-sync-demo) ## Fabric Sync Example Applications @@ -47,7 +47,7 @@ enables a seamless and efficient synchronization process. Run the Fabric Synchronization script: ``` -./examples/fabric-admin/scripts/run_fabric_sync.sh +./examples/fabric-admin/scripts/run_fabric_sync.sh ``` ### Start Fabric Synchronization on Ecosystem 2 @@ -55,7 +55,7 @@ Run the Fabric Synchronization script: Run the Fabric Synchronization script: ``` -./examples/fabric-admin/scripts/run_fabric_sync.sh +./examples/fabric-admin/scripts/run_fabric_sync.sh ``` ## Bootstrap Fabric Sync Demo on RP4 @@ -130,15 +130,15 @@ Pair the Light Example with node ID 3 using its payload number: pairing already-discovered 3 20202021 5540 ``` -After the device is successfully added, you will observe the following on Ecosystem 2 -with the newly assigned Node ID: +After the device is successfully added, you will observe the following on +Ecosystem 2 with the newly assigned Node ID: ``` >>> New device with Node ID: 0x3 has been successfully added. ``` -Additionally, you should also get notified an new device is added on the Ecosystem 2 from -the Ecosystem 1: +Additionally, you should also get notified an new device is added on the +Ecosystem 2 from the Ecosystem 1: ``` >>> A new devie is added on Endpoint 3. @@ -146,8 +146,9 @@ the Ecosystem 1: ### Synchronize Light Example to Ecosystem 1 -After the Light Example is successfully paired in Ecosystem 2, we can start to synchronize -the light device to Ecosystem 1 using the new assigned dynamic endpointid on Ecosystem 2. +After the Light Example is successfully paired in Ecosystem 2, we can start to +synchronize the light device to Ecosystem 1 using the new assigned dynamic +endpointid on Ecosystem 2. ``` fabricsync sync-device @@ -189,8 +190,9 @@ pairing code-wifi ### Synchronize Switch to Ecosystem 1 -After the switch is successfully paired in Ecosystem 2, we can start to synchronize it -to Ecosystem 1 using the new assigned dynamic endpointid on Ecosystem 2.. +After the switch is successfully paired in Ecosystem 2, we can start to +synchronize it to Ecosystem 1 using the new assigned dynamic endpointid on +Ecosystem 2.. ``` fabricsync sync-device @@ -219,5 +221,3 @@ Unpair the switch: ``` pairing unpair ``` - - From 7dc969a699ae53a3d682e8e632f04e956e249772 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Wed, 14 Aug 2024 13:28:35 -0700 Subject: [PATCH 3/5] Update docs/guides/fabric_synchronization_guide.md Co-authored-by: Terence Hampson --- docs/guides/fabric_synchronization_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/fabric_synchronization_guide.md b/docs/guides/fabric_synchronization_guide.md index 22439249a2d943..7f5dfa50081900 100644 --- a/docs/guides/fabric_synchronization_guide.md +++ b/docs/guides/fabric_synchronization_guide.md @@ -141,7 +141,7 @@ Additionally, you should also get notified an new device is added on the Ecosystem 2 from the Ecosystem 1: ``` ->>> A new devie is added on Endpoint 3. +>>> A new device is added on Endpoint 3. ``` ### Synchronize Light Example to Ecosystem 1 From 08fecf2b633b68d1103e1d22d244d12ee9dea90f Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Wed, 14 Aug 2024 13:29:03 -0700 Subject: [PATCH 4/5] Update docs/guides/fabric_synchronization_guide.md Co-authored-by: saurabhst --- docs/guides/fabric_synchronization_guide.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/docs/guides/fabric_synchronization_guide.md b/docs/guides/fabric_synchronization_guide.md index 7f5dfa50081900..b2cfd26d9f439e 100644 --- a/docs/guides/fabric_synchronization_guide.md +++ b/docs/guides/fabric_synchronization_guide.md @@ -137,7 +137,7 @@ Ecosystem 2 with the newly assigned Node ID: >>> New device with Node ID: 0x3 has been successfully added. ``` -Additionally, you should also get notified an new device is added on the +Additionally, you should also get notified when a new device is added to Ecosystem 2 from the Ecosystem 1: ``` From baf9289175056062aa5c518ff368fa340fbb38db Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Wed, 14 Aug 2024 14:20:40 -0700 Subject: [PATCH 5/5] Address review comments --- examples/fabric-admin/commands/fabric-sync/Commands.h | 1 + .../fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp | 2 ++ 2 files changed, 3 insertions(+) diff --git a/examples/fabric-admin/commands/fabric-sync/Commands.h b/examples/fabric-admin/commands/fabric-sync/Commands.h index c1cedd0727b220..94de1d31d8ba09 100644 --- a/examples/fabric-admin/commands/fabric-sync/Commands.h +++ b/examples/fabric-admin/commands/fabric-sync/Commands.h @@ -29,6 +29,7 @@ void registerCommandsFabricSync(Commands & commands, CredentialIssuerCommands * make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), + make_unique(credsIssuerConfig), }; commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for fabric synchronization."); diff --git a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp index dade5932fba758..f62d85ce5afd40 100644 --- a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp +++ b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp @@ -252,6 +252,8 @@ CHIP_ERROR FabricAutoSyncCommand::RunCommand(bool enableAutoSync) // print to console fprintf(stderr, "Auto Fabric Sync is %s.\n", enableAutoSync ? "enabled" : "disabled"); + fprintf(stderr, + "WARNING: The auto-sync command is currently under development and may contain bugs. Use it at your own risk.\n"); return CHIP_NO_ERROR; }