From ed7ef1bcb7eb9c01af329e54cdc50962a1478a36 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Thu, 17 Oct 2024 12:40:29 -0700 Subject: [PATCH] Cleanup AutoSync command (#36128) --- .../commands/fabric-sync/Commands.h | 1 - .../fabric-sync/FabricSyncCommand.cpp | 12 ----------- .../commands/fabric-sync/FabricSyncCommand.h | 19 ----------------- .../device_manager/DeviceManager.cpp | 21 ------------------- .../device_manager/DeviceManager.h | 9 ++------ 5 files changed, 2 insertions(+), 60 deletions(-) diff --git a/examples/fabric-admin/commands/fabric-sync/Commands.h b/examples/fabric-admin/commands/fabric-sync/Commands.h index a6bf1c258f9475..47f7207922beae 100644 --- a/examples/fabric-admin/commands/fabric-sync/Commands.h +++ b/examples/fabric-admin/commands/fabric-sync/Commands.h @@ -31,7 +31,6 @@ void registerCommandsFabricSync(Commands & commands, CredentialIssuerCommands * make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), make_unique(credsIssuerConfig), - make_unique(credsIssuerConfig), }; commands.RegisterCommandSet(clusterName, clusterCommands, "Commands for fabric synchronization."); diff --git a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp index 879d28cd156956..f10db13e939acd 100644 --- a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp +++ b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp @@ -305,15 +305,3 @@ CHIP_ERROR FabricSyncDeviceCommand::RunCommand(EndpointId remoteId) return CHIP_NO_ERROR; } - -CHIP_ERROR FabricAutoSyncCommand::RunCommand(bool enableAutoSync) -{ - DeviceMgr().EnableAutoSync(enableAutoSync); - - // print to console - fprintf(stderr, "Auto Fabric Sync is %s.\n", enableAutoSync ? "enabled" : "disabled"); - fprintf(stderr, - "WARNING: The auto-sync command is currently under development and may contain bugs. Use it at your own risk.\n"); - - 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 16ee40e5b40f3e..8d14529155cab4 100644 --- a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h +++ b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h @@ -136,22 +136,3 @@ class FabricSyncDeviceCommand : public CHIPCommand, public CommissioningWindowDe CHIP_ERROR RunCommand(chip::EndpointId remoteId); }; - -class FabricAutoSyncCommand : public CHIPCommand -{ -public: - FabricAutoSyncCommand(CredentialIssuerCommands * credIssuerCommands) : CHIPCommand("enable-auto-sync", credIssuerCommands) - { - AddArgument("state", 0, 1, &mEnableAutoSync, "Set to true to enable auto Fabric Sync, false to disable."); - } - - /////////// CHIPCommand Interface ///////// - CHIP_ERROR RunCommand() override { return RunCommand(mEnableAutoSync); } - - chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(1); } - -private: - bool mEnableAutoSync; - - CHIP_ERROR RunCommand(bool enableAutoSync); -}; diff --git a/examples/fabric-admin/device_manager/DeviceManager.cpp b/examples/fabric-admin/device_manager/DeviceManager.cpp index 3bfd677d962435..45a40942a27be9 100644 --- a/examples/fabric-admin/device_manager/DeviceManager.cpp +++ b/examples/fabric-admin/device_manager/DeviceManager.cpp @@ -351,14 +351,6 @@ void DeviceManager::HandleAttributePartsListUpdate(TLV::TLVReader & data) { // print to console fprintf(stderr, "A new device is added on Endpoint: %u\n", endpoint); - - if (mAutoSyncEnabled) - { - StringBuilder commandBuilder; - commandBuilder.Add("fabricsync sync-device "); - commandBuilder.AddFormat("%d", endpoint); - PushCommand(commandBuilder.c_str()); - } } // Process removed endpoints @@ -373,19 +365,6 @@ void DeviceManager::HandleAttributePartsListUpdate(TLV::TLVReader & data) ChipLogProgress(NotSpecified, "No device on Endpoint: %u", endpoint); continue; } - - if (mAutoSyncEnabled) - { - NodeId nodeId = device->GetNodeId(); - if (PairingManager::Instance().UnpairDevice(nodeId) != CHIP_NO_ERROR) - { - ChipLogError(NotSpecified, "Failed to unpair device " ChipLogFormatX64, ChipLogValueX64(nodeId)); - } - else - { - PairingManager::Instance().SetPairingDelegate(this); - } - } } } diff --git a/examples/fabric-admin/device_manager/DeviceManager.h b/examples/fabric-admin/device_manager/DeviceManager.h index 43461f41c17229..54d3bf97864820 100644 --- a/examples/fabric-admin/device_manager/DeviceManager.h +++ b/examples/fabric-admin/device_manager/DeviceManager.h @@ -69,14 +69,10 @@ class DeviceManager : public PairingDelegate void SetLocalBridgeSetupPinCode(uint32_t pinCode) { mLocalBridgeSetupPinCode = pinCode; } void SetLocalBridgeNodeId(chip::NodeId nodeId) { mLocalBridgeNodeId = nodeId; } - bool IsAutoSyncEnabled() const { return mAutoSyncEnabled; } - bool IsFabricSyncReady() const { return mRemoteBridgeNodeId != chip::kUndefinedNodeId; } bool IsLocalBridgeReady() const { return mLocalBridgeNodeId != chip::kUndefinedNodeId; } - void EnableAutoSync(bool state) { mAutoSyncEnabled = state; } - void AddSyncedDevice(const Device & device); void RemoveSyncedDevice(chip::NodeId nodeId); @@ -208,9 +204,8 @@ class DeviceManager : public PairingDelegate chip::NodeId mLocalBridgeNodeId = chip::kUndefinedNodeId; std::set mSyncedDevices; - bool mAutoSyncEnabled = false; - bool mInitialized = false; - uint64_t mRequestId = 0; + bool mInitialized = false; + uint64_t mRequestId = 0; BridgeSubscription mBridgeSubscriber; FabricSyncGetter mFabricSyncGetter;