@@ -86,13 +86,14 @@ FabricAdmin::CommissionRemoteBridge(Controller::CommissioningWindowPasscodeParam
86
86
87
87
if (err == CHIP_NO_ERROR)
88
88
{
89
- NodeId nodeId = DeviceManager::Instance ().GetNextAvailableNodeId ();
89
+ mNodeId = DeviceManager::Instance ().GetNextAvailableNodeId ();
90
90
91
91
// After responding with RequestCommissioningApproval to the node where the client initiated the
92
92
// RequestCommissioningApproval, you need to wait for it to open a commissioning window on its bridge.
93
93
usleep (kCommissionPrepareTimeMs * 1000 );
94
94
95
- DeviceManager::Instance ().PairRemoteDevice (nodeId, code.c_str ());
95
+ PairingManager::Instance ().SetPairingDelegate (this );
96
+ DeviceManager::Instance ().PairRemoteDevice (mNodeId , code.c_str ());
96
97
}
97
98
else
98
99
{
@@ -115,6 +116,28 @@ CHIP_ERROR FabricAdmin::KeepActive(ScopedNodeId scopedNodeId, uint32_t stayActiv
115
116
return CHIP_NO_ERROR;
116
117
}
117
118
119
+ void FabricAdmin::OnCommissioningComplete (NodeId deviceId, CHIP_ERROR err)
120
+ {
121
+ if (mNodeId != deviceId)
122
+ {
123
+ ChipLogError (NotSpecified, " Tried to pair a non-bridge device (0x:" ChipLogFormatX64 " ) with result: %" CHIP_ERROR_FORMAT,
124
+ ChipLogValueX64 (deviceId), err.Format ());
125
+ return ;
126
+ }
127
+
128
+ if (err == CHIP_NO_ERROR)
129
+ {
130
+ DeviceManager::Instance ().SetRemoteBridgeNodeId (deviceId);
131
+ }
132
+ else
133
+ {
134
+ ChipLogError (NotSpecified, " Failed to pair bridge device (0x:" ChipLogFormatX64 " ) with error: %" CHIP_ERROR_FORMAT,
135
+ ChipLogValueX64 (deviceId), err.Format ());
136
+ }
137
+
138
+ mNodeId = kUndefinedNodeId ;
139
+ }
140
+
118
141
void FabricAdmin::ScheduleSendingKeepActiveOnCheckIn (ScopedNodeId scopedNodeId, uint32_t stayActiveDurationMs, uint32_t timeoutMs)
119
142
{
120
143
// Accessing mPendingCheckIn should only be done while holding ChipStackLock
0 commit comments