@@ -35,18 +35,28 @@ namespace {
35
35
// Constants
36
36
constexpr uint32_t kCommissionPrepareTimeMs = 500 ;
37
37
constexpr uint16_t kMaxManaulCodeLength = 21 ;
38
- constexpr uint16_t kSubscribeMinInterval = 0 ;
39
- constexpr uint16_t kSubscribeMaxInterval = 60 ;
40
- constexpr uint16_t kRemoteBridgePort = 5540 ;
38
+
39
+ void CheckFabricBridgeSynchronizationSupport (intptr_t ignored)
40
+ {
41
+ DeviceMgr ().ReadSupportedDeviceCategories ();
42
+ }
41
43
42
44
} // namespace
43
45
44
46
void FabricSyncAddBridgeCommand::OnCommissioningComplete (chip::NodeId deviceId, CHIP_ERROR err)
45
47
{
46
48
if (mBridgeNodeId != deviceId)
47
49
{
48
- ChipLogProgress (NotSpecified, " Commissioning complete for non-bridge device: NodeId: " ChipLogFormatX64,
49
- ChipLogValueX64 (deviceId));
50
+ if (err != CHIP_NO_ERROR)
51
+ {
52
+ ChipLogError (NotSpecified, " Failed to pair non-bridge device (0x:" ChipLogFormatX64 " ) with error: %" CHIP_ERROR_FORMAT,
53
+ ChipLogValueX64 (deviceId), err.Format ());
54
+ }
55
+ else
56
+ {
57
+ ChipLogProgress (NotSpecified, " Commissioning complete for non-bridge device: NodeId: " ChipLogFormatX64,
58
+ ChipLogValueX64 (deviceId));
59
+ }
50
60
return ;
51
61
}
52
62
@@ -56,11 +66,15 @@ void FabricSyncAddBridgeCommand::OnCommissioningComplete(chip::NodeId deviceId,
56
66
ChipLogProgress (NotSpecified, " Successfully paired bridge device: NodeId: " ChipLogFormatX64,
57
67
ChipLogValueX64 (mBridgeNodeId ));
58
68
59
- char command[kMaxCommandSize ];
60
- snprintf (command, sizeof (command), " descriptor subscribe parts-list %d %d %ld %d" , kSubscribeMinInterval ,
61
- kSubscribeMaxInterval , mBridgeNodeId , kAggragatorEndpointId );
69
+ DeviceMgr ().SubscribeRemoteFabricBridge ();
62
70
63
- PushCommand (command);
71
+ // After successful commissioning of the Commissionee, initiate Reverse Commissioning
72
+ // via the Commissioner Control Cluster. However, we must first verify that the
73
+ // remote Fabric-Bridge supports Fabric Synchronization.
74
+ //
75
+ // Note: The Fabric-Admin MUST NOT send the RequestCommissioningApproval command
76
+ // if the remote Fabric-Bridge lacks Fabric Synchronization support.
77
+ DeviceLayer::PlatformMgr ().ScheduleWork (CheckFabricBridgeSynchronizationSupport, 0 );
64
78
}
65
79
else
66
80
{
@@ -80,10 +94,6 @@ CHIP_ERROR FabricSyncAddBridgeCommand::RunCommand(NodeId remoteId)
80
94
return CHIP_NO_ERROR;
81
95
}
82
96
83
- char command[kMaxCommandSize ];
84
- snprintf (command, sizeof (command), " pairing already-discovered %ld %d %s %d" , remoteId, kSetupPinCode ,
85
- reinterpret_cast <const char *>(mRemoteAddr .data ()), kRemoteBridgePort );
86
-
87
97
PairingCommand * pairingCommand = static_cast <PairingCommand *>(CommandMgr ().GetCommandByName (" pairing" , " already-discovered" ));
88
98
89
99
if (pairingCommand == nullptr )
@@ -95,7 +105,7 @@ CHIP_ERROR FabricSyncAddBridgeCommand::RunCommand(NodeId remoteId)
95
105
pairingCommand->RegisterCommissioningDelegate (this );
96
106
mBridgeNodeId = remoteId;
97
107
98
- PushCommand (command );
108
+ DeviceMgr (). PairRemoteFabricBridge (remoteId, reinterpret_cast < const char *>( mRemoteAddr . data ()) );
99
109
100
110
return CHIP_NO_ERROR;
101
111
}
@@ -136,9 +146,6 @@ CHIP_ERROR FabricSyncRemoveBridgeCommand::RunCommand()
136
146
137
147
mBridgeNodeId = bridgeNodeId;
138
148
139
- char command[kMaxCommandSize ];
140
- snprintf (command, sizeof (command), " pairing unpair %ld" , mBridgeNodeId );
141
-
142
149
PairingCommand * pairingCommand = static_cast <PairingCommand *>(CommandMgr ().GetCommandByName (" pairing" , " unpair" ));
143
150
144
151
if (pairingCommand == nullptr )
@@ -149,7 +156,7 @@ CHIP_ERROR FabricSyncRemoveBridgeCommand::RunCommand()
149
156
150
157
pairingCommand->RegisterPairingDelegate (this );
151
158
152
- PushCommand (command );
159
+ DeviceMgr (). UnpairRemoteFabricBridge ( );
153
160
154
161
return CHIP_NO_ERROR;
155
162
}
@@ -163,9 +170,7 @@ void FabricSyncDeviceCommand::OnCommissioningWindowOpened(NodeId deviceId, CHIP_
163
170
CHIP_ERROR error = ManualSetupPayloadGenerator (payload).payloadDecimalStringRepresentation (manualCode);
164
171
if (error == CHIP_NO_ERROR)
165
172
{
166
- char command[kMaxCommandSize ];
167
173
NodeId nodeId = DeviceMgr ().GetNextAvailableNodeId ();
168
- snprintf (command, sizeof (command), " pairing code %ld %s" , nodeId, payloadBuffer);
169
174
170
175
PairingCommand * pairingCommand = static_cast <PairingCommand *>(CommandMgr ().GetCommandByName (" pairing" , " code" ));
171
176
@@ -180,7 +185,7 @@ void FabricSyncDeviceCommand::OnCommissioningWindowOpened(NodeId deviceId, CHIP_
180
185
181
186
usleep (kCommissionPrepareTimeMs * 1000 );
182
187
183
- PushCommand (command );
188
+ DeviceMgr (). PairRemoteDevice (nodeId, payloadBuffer );
184
189
}
185
190
else
186
191
{
@@ -224,10 +229,6 @@ CHIP_ERROR FabricSyncDeviceCommand::RunCommand(EndpointId remoteId)
224
229
return CHIP_NO_ERROR;
225
230
}
226
231
227
- char command[kMaxCommandSize ];
228
- snprintf (command, sizeof (command), " pairing open-commissioning-window %ld %d %d %d %d %d" , DeviceMgr ().GetRemoteBridgeNodeId (),
229
- remoteId, kEnhancedCommissioningMethod , kWindowTimeout , kIteration , kDiscriminator );
230
-
231
232
OpenCommissioningWindowCommand * openCommand =
232
233
static_cast <OpenCommissioningWindowCommand *>(CommandMgr ().GetCommandByName (" pairing" , " open-commissioning-window" ));
233
234
@@ -238,7 +239,7 @@ CHIP_ERROR FabricSyncDeviceCommand::RunCommand(EndpointId remoteId)
238
239
239
240
openCommand->RegisterDelegate (this );
240
241
241
- PushCommand (command );
242
+ DeviceMgr (). OpenRemoteDeviceCommissioningWindow (remoteId );
242
243
243
244
return CHIP_NO_ERROR;
244
245
}
0 commit comments