Skip to content

Commit 1c655f9

Browse files
authored
[Fabric-Admin] Fix failing cleanup bridge after bridge is removed (project-chip#36375)
1 parent 2a7106f commit 1c655f9

File tree

5 files changed

+22
-13
lines changed

5 files changed

+22
-13
lines changed

examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -83,7 +83,7 @@ CHIP_ERROR FabricSyncAddBridgeCommand::RunCommand(NodeId remoteId)
8383
if (DeviceMgr().IsFabricSyncReady())
8484
{
8585
// print to console
86-
fprintf(stderr, "Remote Fabric Bridge has already been configured.");
86+
fprintf(stderr, "Remote Fabric Bridge has already been configured.\n");
8787
return CHIP_NO_ERROR;
8888
}
8989

@@ -126,7 +126,7 @@ CHIP_ERROR FabricSyncRemoveBridgeCommand::RunCommand()
126126
if (bridgeNodeId == kUndefinedNodeId)
127127
{
128128
// print to console
129-
fprintf(stderr, "Remote Fabric Bridge is not configured yet, nothing to remove.");
129+
fprintf(stderr, "Remote Fabric Bridge is not configured yet, nothing to remove.\n");
130130
return CHIP_NO_ERROR;
131131
}
132132

@@ -176,7 +176,7 @@ CHIP_ERROR FabricSyncAddLocalBridgeCommand::RunCommand(NodeId deviceId)
176176
if (DeviceMgr().IsLocalBridgeReady())
177177
{
178178
// print to console
179-
fprintf(stderr, "Local Fabric Bridge has already been configured.");
179+
fprintf(stderr, "Local Fabric Bridge has already been configured.\n");
180180
return CHIP_NO_ERROR;
181181
}
182182

@@ -227,7 +227,7 @@ CHIP_ERROR FabricSyncRemoveLocalBridgeCommand::RunCommand()
227227
if (bridgeNodeId == kUndefinedNodeId)
228228
{
229229
// print to console
230-
fprintf(stderr, "Local Fabric Bridge is not configured yet, nothing to remove.");
230+
fprintf(stderr, "Local Fabric Bridge is not configured yet, nothing to remove.\n");
231231
return CHIP_NO_ERROR;
232232
}
233233

@@ -292,18 +292,18 @@ void FabricSyncDeviceCommand::OnCommissioningComplete(NodeId deviceId, CHIP_ERRO
292292
}
293293
}
294294

295-
CHIP_ERROR FabricSyncDeviceCommand::RunCommand(EndpointId remoteId)
295+
CHIP_ERROR FabricSyncDeviceCommand::RunCommand(EndpointId remoteEndpointId)
296296
{
297297
if (!DeviceMgr().IsFabricSyncReady())
298298
{
299299
// print to console
300-
fprintf(stderr, "Remote Fabric Bridge is not configured yet.");
300+
fprintf(stderr, "Remote Fabric Bridge is not configured yet.\n");
301301
return CHIP_NO_ERROR;
302302
}
303303

304304
PairingManager::Instance().SetOpenCommissioningWindowDelegate(this);
305305

306-
DeviceMgr().OpenRemoteDeviceCommissioningWindow(remoteId);
306+
DeviceMgr().OpenRemoteDeviceCommissioningWindow(remoteEndpointId);
307307

308308
return CHIP_NO_ERROR;
309309
}

examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ class FabricSyncDeviceCommand : public CHIPCommand, public CommissioningWindowDe
124124
AddArgument("endpointid", 0, UINT16_MAX, &mRemoteEndpointId);
125125
}
126126

127-
void OnCommissioningWindowOpened(NodeId deviceId, CHIP_ERROR status, chip::SetupPayload payload) override;
128-
void OnCommissioningComplete(NodeId deviceId, CHIP_ERROR err) override;
127+
void OnCommissioningWindowOpened(chip::NodeId deviceId, CHIP_ERROR status, chip::SetupPayload payload) override;
128+
void OnCommissioningComplete(chip::NodeId deviceId, CHIP_ERROR err) override;
129129

130130
/////////// CHIPCommand Interface /////////
131131
CHIP_ERROR RunCommand() override { return RunCommand(mRemoteEndpointId); }
@@ -136,7 +136,7 @@ class FabricSyncDeviceCommand : public CHIPCommand, public CommissioningWindowDe
136136
chip::EndpointId mRemoteEndpointId = chip::kInvalidEndpointId;
137137
chip::NodeId mAssignedNodeId = chip::kUndefinedNodeId;
138138

139-
CHIP_ERROR RunCommand(chip::EndpointId remoteId);
139+
CHIP_ERROR RunCommand(chip::EndpointId remoteEndpointId);
140140
};
141141

142142
} // namespace admin

examples/fabric-admin/device_manager/DeviceManager.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,7 +71,11 @@ void DeviceManager::UpdateLastUsedNodeId(NodeId nodeId)
7171
void DeviceManager::SetRemoteBridgeNodeId(chip::NodeId nodeId)
7272
{
7373
mRemoteBridgeNodeId = nodeId;
74-
mCommissionerControl.Init(PairingManager::Instance().CurrentCommissioner(), mRemoteBridgeNodeId, kAggregatorEndpointId);
74+
75+
if (mRemoteBridgeNodeId != kUndefinedNodeId)
76+
{
77+
mCommissionerControl.Init(PairingManager::Instance().CurrentCommissioner(), mRemoteBridgeNodeId, kAggregatorEndpointId);
78+
}
7579
}
7680

7781
void DeviceManager::AddSyncedDevice(const Device & device)

examples/fabric-admin/device_manager/PairingManager.cpp

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,12 @@ void PairingManager::OnCurrentFabricRemove(void * context, NodeId nodeId, CHIP_E
550550
if (err == CHIP_NO_ERROR)
551551
{
552552
// print to console
553-
fprintf(stderr, "Device with Node ID: " ChipLogFormatX64 "has been successfully removed.\n", ChipLogValueX64(nodeId));
553+
fprintf(stderr, "Device with Node ID: " ChipLogFormatX64 " has been successfully removed.\n", ChipLogValueX64(nodeId));
554+
555+
if (self->mPairingDelegate)
556+
{
557+
self->mPairingDelegate->OnDeviceRemoved(nodeId, err);
558+
}
554559

555560
#if defined(PW_RPC_ENABLED)
556561
FabricIndex fabricIndex = self->CurrentCommissioner().GetFabricIndex();

examples/fabric-admin/rpc/RpcClient.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ CHIP_ERROR WaitForResponse(CallType & call)
5959
}
6060
else
6161
{
62-
fprintf(stderr, "RPC Response timed out!");
62+
fprintf(stderr, "RPC Response timed out!\n");
6363
return CHIP_ERROR_TIMEOUT;
6464
}
6565
}

0 commit comments

Comments
 (0)