[Fabric-Admin] Fix failing cleanup bridge after bridge is removed (#36375)
diff --git a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp
index 6d42b04..e21f02f 100644
--- a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp
+++ b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp
@@ -83,7 +83,7 @@
if (DeviceMgr().IsFabricSyncReady())
{
// print to console
- fprintf(stderr, "Remote Fabric Bridge has already been configured.");
+ fprintf(stderr, "Remote Fabric Bridge has already been configured.\n");
return CHIP_NO_ERROR;
}
@@ -126,7 +126,7 @@
if (bridgeNodeId == kUndefinedNodeId)
{
// print to console
- fprintf(stderr, "Remote Fabric Bridge is not configured yet, nothing to remove.");
+ fprintf(stderr, "Remote Fabric Bridge is not configured yet, nothing to remove.\n");
return CHIP_NO_ERROR;
}
@@ -176,7 +176,7 @@
if (DeviceMgr().IsLocalBridgeReady())
{
// print to console
- fprintf(stderr, "Local Fabric Bridge has already been configured.");
+ fprintf(stderr, "Local Fabric Bridge has already been configured.\n");
return CHIP_NO_ERROR;
}
@@ -227,7 +227,7 @@
if (bridgeNodeId == kUndefinedNodeId)
{
// print to console
- fprintf(stderr, "Local Fabric Bridge is not configured yet, nothing to remove.");
+ fprintf(stderr, "Local Fabric Bridge is not configured yet, nothing to remove.\n");
return CHIP_NO_ERROR;
}
@@ -292,18 +292,18 @@
}
}
-CHIP_ERROR FabricSyncDeviceCommand::RunCommand(EndpointId remoteId)
+CHIP_ERROR FabricSyncDeviceCommand::RunCommand(EndpointId remoteEndpointId)
{
if (!DeviceMgr().IsFabricSyncReady())
{
// print to console
- fprintf(stderr, "Remote Fabric Bridge is not configured yet.");
+ fprintf(stderr, "Remote Fabric Bridge is not configured yet.\n");
return CHIP_NO_ERROR;
}
PairingManager::Instance().SetOpenCommissioningWindowDelegate(this);
- DeviceMgr().OpenRemoteDeviceCommissioningWindow(remoteId);
+ DeviceMgr().OpenRemoteDeviceCommissioningWindow(remoteEndpointId);
return CHIP_NO_ERROR;
}
diff --git a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h
index 809cc7d..82442ac 100644
--- a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h
+++ b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h
@@ -124,8 +124,8 @@
AddArgument("endpointid", 0, UINT16_MAX, &mRemoteEndpointId);
}
- void OnCommissioningWindowOpened(NodeId deviceId, CHIP_ERROR status, chip::SetupPayload payload) override;
- void OnCommissioningComplete(NodeId deviceId, CHIP_ERROR err) override;
+ void OnCommissioningWindowOpened(chip::NodeId deviceId, CHIP_ERROR status, chip::SetupPayload payload) override;
+ void OnCommissioningComplete(chip::NodeId deviceId, CHIP_ERROR err) override;
/////////// CHIPCommand Interface /////////
CHIP_ERROR RunCommand() override { return RunCommand(mRemoteEndpointId); }
@@ -136,7 +136,7 @@
chip::EndpointId mRemoteEndpointId = chip::kInvalidEndpointId;
chip::NodeId mAssignedNodeId = chip::kUndefinedNodeId;
- CHIP_ERROR RunCommand(chip::EndpointId remoteId);
+ CHIP_ERROR RunCommand(chip::EndpointId remoteEndpointId);
};
} // namespace admin
diff --git a/examples/fabric-admin/device_manager/DeviceManager.cpp b/examples/fabric-admin/device_manager/DeviceManager.cpp
index fafae0e..7546f50 100644
--- a/examples/fabric-admin/device_manager/DeviceManager.cpp
+++ b/examples/fabric-admin/device_manager/DeviceManager.cpp
@@ -71,7 +71,11 @@
void DeviceManager::SetRemoteBridgeNodeId(chip::NodeId nodeId)
{
mRemoteBridgeNodeId = nodeId;
- mCommissionerControl.Init(PairingManager::Instance().CurrentCommissioner(), mRemoteBridgeNodeId, kAggregatorEndpointId);
+
+ if (mRemoteBridgeNodeId != kUndefinedNodeId)
+ {
+ mCommissionerControl.Init(PairingManager::Instance().CurrentCommissioner(), mRemoteBridgeNodeId, kAggregatorEndpointId);
+ }
}
void DeviceManager::AddSyncedDevice(const Device & device)
diff --git a/examples/fabric-admin/device_manager/PairingManager.cpp b/examples/fabric-admin/device_manager/PairingManager.cpp
index 64e4fb4..b13af2d 100644
--- a/examples/fabric-admin/device_manager/PairingManager.cpp
+++ b/examples/fabric-admin/device_manager/PairingManager.cpp
@@ -550,7 +550,12 @@
if (err == CHIP_NO_ERROR)
{
// print to console
- fprintf(stderr, "Device with Node ID: " ChipLogFormatX64 "has been successfully removed.\n", ChipLogValueX64(nodeId));
+ fprintf(stderr, "Device with Node ID: " ChipLogFormatX64 " has been successfully removed.\n", ChipLogValueX64(nodeId));
+
+ if (self->mPairingDelegate)
+ {
+ self->mPairingDelegate->OnDeviceRemoved(nodeId, err);
+ }
#if defined(PW_RPC_ENABLED)
FabricIndex fabricIndex = self->CurrentCommissioner().GetFabricIndex();
diff --git a/examples/fabric-admin/rpc/RpcClient.cpp b/examples/fabric-admin/rpc/RpcClient.cpp
index a3bc459..f99d925 100644
--- a/examples/fabric-admin/rpc/RpcClient.cpp
+++ b/examples/fabric-admin/rpc/RpcClient.cpp
@@ -59,7 +59,7 @@
}
else
{
- fprintf(stderr, "RPC Response timed out!");
+ fprintf(stderr, "RPC Response timed out!\n");
return CHIP_ERROR_TIMEOUT;
}
}