Skip to content

Commit e188180

Browse files
authored
Merge branch 'master' into feature/refresh-content-app-acl
2 parents 55f4288 + c70a769 commit e188180

File tree

11 files changed

+485
-59
lines changed

11 files changed

+485
-59
lines changed
+164
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,164 @@
1+
# Fabric Synchronization Guide
2+
3+
- [Fabric Synchronization Guide](#fabric-synchronization-guide)
4+
- [Fabric Sync Example Applications](#fabric-sync-example-applications)
5+
- [Run Fabric Sync Demo on RP4](#run-fabric-sync-demo-on-rp4)
6+
7+
## Fabric Sync Example Applications
8+
9+
Fabric-Admin and Fabric-Bridge example applications are provided to demonstrate
10+
Fabric Synchronization feature. You can find them in the examples.
11+
12+
![matter_fabric_synchronization](images/matter_fabric_synchronization.png)
13+
14+
Fabric-Admin example app implements the Fabric Administrator role and
15+
communicates with the Fabric-Bridge-App on the other side, facilitating the
16+
Fabric Synchronization process.
17+
18+
Fabric-Bridge-App example app implements the Aggregator device type with Fabric
19+
Synchronization condition met and demonstrates the end-to-end Fabric
20+
Synchronization feature using dynamic endpoints.
21+
22+
Fabric Synchronization can be triggered from either side. The initiator of the
23+
Fabric Synchronization process, who shares their devices, takes on the
24+
Commissioner role. The recipient of the Fabric Synchronization request, who
25+
receives the shared devices, assumes the Commissionee role. This flexibility
26+
enables a seamless and efficient synchronization process.
27+
28+
### Building the Example Application
29+
30+
- Building the Fabric-Admin Application
31+
32+
[Fabric-Admin](https://github.com/project-chip/connectedhomeip/tree/master/examples/fabric-admin/README.md)
33+
34+
* Building the Fabric-Bridge Application
35+
36+
[Fabric-Bridge](https://github.com/project-chip/connectedhomeip/tree/master/examples/fabric-bridge-app/linux/README.md)
37+
38+
## Run Fabric Sync Demo on RP4
39+
40+
### Setup Fabric Source
41+
42+
Connect to the Fabric Source server:
43+
44+
```
45+
ssh ubuntu@xxx.xxx.xxx.xxx
46+
```
47+
48+
Password: <password>
49+
50+
Run the Fabric Source script:
51+
52+
```
53+
./run_fabric_source.sh
54+
```
55+
56+
### Setup Fabric Sink
57+
58+
Connect to the Fabric Sink server:
59+
60+
```
61+
ssh ubuntu@xxx.xxx.xxx.xxx
62+
```
63+
64+
Password: <password>
65+
66+
Run the Fabric Sink script:
67+
68+
```
69+
./run_fabric_sink.sh
70+
```
71+
72+
### Fabric Sync Setup
73+
74+
Enable Fabric Auto Sync:
75+
76+
In Fabric-Sync console:
77+
78+
```
79+
fabricsync enable-auto-sync 1
80+
```
81+
82+
Pair the Fabric-Source bridge to Fabric-Sync with node ID 1:
83+
84+
```
85+
fabricsync add-bridge 1 <fabric-sink-ip>
86+
```
87+
88+
### Pair Light Example to Fabric-Source
89+
90+
Pair the Light Example with node ID 3 using its payload number:
91+
92+
```
93+
pairing already-discovered 3 20202021 <ip> 5540
94+
```
95+
96+
After the Light Example is successfully paired in Fabric-Source, it will be
97+
synced to Fabric-Sink with a new assigned node ID.
98+
99+
Toggle the Light Example:
100+
101+
From Fabric-Source:
102+
103+
```
104+
onoff on <node-id> 1
105+
onoff off <node-id> 1
106+
```
107+
108+
From Fabric-Sink: (Use the node ID assigned)
109+
110+
```
111+
onoff on x 1
112+
onoff off x 1
113+
```
114+
115+
### Remove Light Example from Fabric-Source
116+
117+
Unpair the Light Example:
118+
119+
```
120+
pairing unpair <node-id>
121+
```
122+
123+
After the Light Example is successfully unpaired from Fabric-Source, it will
124+
also be removed from the Fabric-Sink.
125+
126+
### Pair Commercial Switch to Fabric-Source
127+
128+
Pair the switch using its payload number:
129+
130+
In Fabric-Source console:
131+
132+
```
133+
pairing code-wifi <node-id> <ssid> <passwd> <payload>
134+
```
135+
136+
After the switch is successfully paired in Fabric-Source, it will be synced to
137+
Fabric-Sink with a new assigned node ID.
138+
139+
Toggle the switch:
140+
141+
From Fabric-Source:
142+
143+
```
144+
onoff on <node-id> 1
145+
onoff off <node-id> 1
146+
```
147+
148+
From Fabric-Sink: (Use the node ID assigned)
149+
150+
```
151+
onoff on <node-id> 1
152+
onoff off <node-id> 1
153+
```
154+
155+
### Remove Switch from Fabric-Source
156+
157+
Unpair the switch:
158+
159+
```
160+
pairing unpair <node-id>
161+
```
162+
163+
After the switch is successfully unpaired from Fabric-Source, it will also be
164+
removed from the Fabric-Sink.
Loading
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
#!/bin/bash
2+
3+
# Default paths
4+
DEFAULT_CHOICES=(
5+
"./fabric-admin"
6+
"out/debug/standalone/fabric-admin"
7+
"out/linux-x64-fabric-admin/fabric-admin"
8+
"out/darwin-arm64-fabric-admin/fabric-admin"
9+
)
10+
FABRIC_ADMIN_LOG="/tmp/fabric_admin.log"
11+
FABRIC_ADMIN_PATH=""
12+
13+
# Function to find fabric-admin binary
14+
find_fabric_admin() {
15+
local choices=("$@")
16+
for path in "${choices[@]}"; do
17+
if [[ -e "$path" ]]; then
18+
echo "$path"
19+
return 0
20+
fi
21+
done
22+
return 1
23+
}
24+
25+
# Parse arguments
26+
VERBOSE=false
27+
SPECIFIED_PATH=""
28+
29+
for arg in "$@"; do
30+
case $arg in
31+
--verbose)
32+
VERBOSE=true
33+
;;
34+
--path=*)
35+
SPECIFIED_PATH="${arg#*=}"
36+
;;
37+
esac
38+
done
39+
40+
# Use specified path if provided
41+
if [[ -n "$SPECIFIED_PATH" ]]; then
42+
if [[ -e "$SPECIFIED_PATH" ]]; then
43+
FABRIC_ADMIN_PATH="$SPECIFIED_PATH"
44+
else
45+
echo >&2 "Specified path does not exist: $SPECIFIED_PATH"
46+
exit 1
47+
fi
48+
else
49+
FABRIC_ADMIN_PATH=$(find_fabric_admin "${DEFAULT_CHOICES[@]}")
50+
if [[ $? -ne 0 ]]; then
51+
echo >&2 "Could not find the fabric-admin binary"
52+
exit 1
53+
fi
54+
fi
55+
56+
echo "PATH IS: $FABRIC_ADMIN_PATH"
57+
58+
# Kill fabric-admin if it is running
59+
echo "Checking for running fabric-admin process..."
60+
fabric_admin_pid=$(pgrep -f "$FABRIC_ADMIN_PATH")
61+
if [[ -n "$fabric_admin_pid" ]]; then
62+
echo "Found fabric-admin with PID $fabric_admin_pid, attempting to kill..."
63+
kill -9 "$fabric_admin_pid"
64+
echo "Killed fabric-admin with PID $fabric_admin_pid"
65+
fi
66+
67+
# Remove /tmp/chip_* files and directories
68+
echo "Removing /tmp/chip_* files and directories..."
69+
sudo rm -rf /tmp/chip_*
70+
echo "Removed /tmp/chip_* files and directories"
71+
72+
# Start fabric-admin with or without log file path based on --verbose option
73+
echo "Starting fabric-admin..."
74+
if [ "$VERBOSE" = true ]; then
75+
"$FABRIC_ADMIN_PATH"
76+
else
77+
"$FABRIC_ADMIN_PATH" --log-file-path "$FABRIC_ADMIN_LOG"
78+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
#!/bin/bash
2+
3+
# Get the path to the current script
4+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
5+
6+
# Default paths
7+
DEFAULT_ADMIN_CHOICES=(
8+
"./fabric-admin"
9+
"out/debug/standalone/fabric-admin"
10+
"out/linux-x64-fabric-admin/fabric-admin"
11+
"out/darwin-arm64-fabric-admin/fabric-admin"
12+
)
13+
DEFAULT_BRIDGE_CHOICES=(
14+
"./fabric-bridge-app"
15+
"out/debug/standalone/fabric-bridge-app"
16+
"out/linux-x64-fabric-bridge-app/fabric-bridge-app"
17+
"out/darwin-arm64-fabric-bridge-app/fabric-bridge-app"
18+
)
19+
FABRIC_ADMIN_LOG="/tmp/fabric_admin.log"
20+
FABRIC_BRIDGE_APP_LOG="/tmp/fabric_bridge_app.log"
21+
FABRIC_ADMIN_PATH=""
22+
FABRIC_BRIDGE_APP_PATH=""
23+
24+
# Function to find a binary
25+
find_binary() {
26+
local choices=("$@")
27+
for path in "${choices[@]}"; do
28+
if [[ -e "$path" ]]; then
29+
echo "$path"
30+
return 0
31+
fi
32+
done
33+
return 1
34+
}
35+
36+
# Parse arguments
37+
VERBOSE=false
38+
SPECIFIED_ADMIN_PATH=""
39+
SPECIFIED_BRIDGE_PATH=""
40+
41+
for arg in "$@"; do
42+
case $arg in
43+
--verbose)
44+
VERBOSE=true
45+
;;
46+
--admin-path=*)
47+
SPECIFIED_ADMIN_PATH="${arg#*=}"
48+
;;
49+
--bridge-path=*)
50+
SPECIFIED_BRIDGE_PATH="${arg#*=}"
51+
;;
52+
esac
53+
done
54+
55+
# Use specified paths if provided
56+
if [[ -n "$SPECIFIED_ADMIN_PATH" ]]; then
57+
if [[ -e "$SPECIFIED_ADMIN_PATH" ]]; then
58+
FABRIC_ADMIN_PATH="$SPECIFIED_ADMIN_PATH"
59+
else
60+
echo >&2 "Specified admin path does not exist: $SPECIFIED_ADMIN_PATH"
61+
exit 1
62+
fi
63+
else
64+
FABRIC_ADMIN_PATH=$(find_binary "${DEFAULT_ADMIN_CHOICES[@]}")
65+
if [[ $? -ne 0 ]]; then
66+
echo >&2 "Could not find the fabric-admin binary"
67+
exit 1
68+
fi
69+
fi
70+
71+
if [[ -n "$SPECIFIED_BRIDGE_PATH" ]]; then
72+
if [[ -e "$SPECIFIED_BRIDGE_PATH" ]]; then
73+
FABRIC_BRIDGE_APP_PATH="$SPECIFIED_BRIDGE_PATH"
74+
else
75+
echo >&2 "Specified bridge path does not exist: $SPECIFIED_BRIDGE_PATH"
76+
exit 1
77+
fi
78+
else
79+
FABRIC_BRIDGE_APP_PATH=$(find_binary "${DEFAULT_BRIDGE_CHOICES[@]}")
80+
if [[ $? -ne 0 ]]; then
81+
echo >&2 "Could not find the fabric-bridge-app binary"
82+
exit 1
83+
fi
84+
fi
85+
86+
echo "Admin path: $FABRIC_ADMIN_PATH"
87+
echo "Bridge path: $FABRIC_BRIDGE_APP_PATH"
88+
89+
# Determine the path to stop_fabric_source.sh based on the location of run_fabric_source.sh
90+
RUN_FABRIC_SOURCE_PATH=$(find_binary "$SCRIPT_DIR/run_fabric_source.sh")
91+
if [[ $? -ne 0 ]]; then
92+
echo >&2 "Could not find the run_fabric_source.sh script"
93+
exit 1
94+
fi
95+
STOP_FABRIC_SOURCE_PATH="${RUN_FABRIC_SOURCE_PATH/run_fabric_source/stop_fabric_source}"
96+
97+
# Stop any running instances and clean up
98+
if [[ -e "$STOP_FABRIC_SOURCE_PATH" ]]; then
99+
"$STOP_FABRIC_SOURCE_PATH"
100+
else
101+
echo >&2 "Could not find the stop_fabric_source.sh script"
102+
exit 1
103+
fi
104+
105+
# Start fabric-bridge-app if available and redirect its output to /dev/null
106+
if [ -f "$FABRIC_BRIDGE_APP_PATH" ]; then
107+
"$FABRIC_BRIDGE_APP_PATH" >"$FABRIC_BRIDGE_APP_LOG" 2>&1 &
108+
echo "Started fabric-bridge-app"
109+
fi
110+
111+
# Start fabric-admin with or without log file path based on --verbose option
112+
if [ "$VERBOSE" = true ]; then
113+
"$FABRIC_ADMIN_PATH"
114+
else
115+
"$FABRIC_ADMIN_PATH" --log-file-path "$FABRIC_ADMIN_LOG"
116+
fi
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,22 @@
1+
#!/bin/bash
2+
3+
FABRIC_ADMIN_PATH="/fabric-admin"
4+
FABRIC_BRIDGE_APP_PATH="/fabric-bridge-app"
5+
6+
# Kill fabric-admin if it is running
7+
fabric_admin_pid=$(pgrep -f "$FABRIC_ADMIN_PATH")
8+
if [ ! -z "$fabric_admin_pid" ]; then
9+
kill -9 "$fabric_admin_pid"
10+
echo "Killed fabric-admin with PID $fabric_admin_pid"
11+
fi
12+
13+
# Kill fabric-bridge-app if it is running
14+
fabric_bridge_app_pid=$(pgrep -f "$FABRIC_BRIDGE_APP_PATH")
15+
if [ ! -z "$fabric_bridge_app_pid" ]; then
16+
kill -9 "$fabric_bridge_app_pid"
17+
echo "Killed fabric-bridge-app with PID $fabric_bridge_app_pid"
18+
fi
19+
20+
# Remove /tmp/chip_* files and directories
21+
sudo rm -rf /tmp/chip_*
22+
echo "Removed /tmp/chip_* files and directories"

0 commit comments

Comments
 (0)