From 73fb3254fff9f83114c04ab97509e954247e4b62 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Tue, 12 Nov 2024 14:00:54 -0800 Subject: [PATCH] Add debug log --- examples/fabric-sync/admin/FabricAdmin.cpp | 2 +- examples/fabric-sync/admin/FabricAdmin.h | 4 ++-- .../bridge/include/FabricAdminDelegate.h | 8 ++++---- .../bridge/src/CommissionerControlDelegate.cpp | 16 ++++++++-------- examples/fabric-sync/shell/AddBridgeCommand.cpp | 3 +++ examples/fabric-sync/shell/AddDeviceCommand.cpp | 3 +++ .../fabric-sync/shell/RemoveBridgeCommand.cpp | 2 ++ .../fabric-sync/shell/RemoveDeviceCommand.cpp | 2 ++ examples/fabric-sync/shell/ShellCommands.cpp | 3 +-- 9 files changed, 26 insertions(+), 17 deletions(-) diff --git a/examples/fabric-sync/admin/FabricAdmin.cpp b/examples/fabric-sync/admin/FabricAdmin.cpp index 9f05313ab82018..a012ac9d8c9a95 100644 --- a/examples/fabric-sync/admin/FabricAdmin.cpp +++ b/examples/fabric-sync/admin/FabricAdmin.cpp @@ -39,7 +39,7 @@ FabricAdmin & FabricAdmin::Instance() } CHIP_ERROR -FabricAdmin::CommissionNode(Controller::CommissioningWindowPasscodeParams params, VendorId vendorId, uint16_t productId) +FabricAdmin::CommissionRemoteBridge(Controller::CommissioningWindowPasscodeParams params, VendorId vendorId, uint16_t productId) { char saltHex[Crypto::kSpake2p_Max_PBKDF_Salt_Length * 2 + 1]; Encoding::BytesToHex(params.GetSalt().data(), params.GetSalt().size(), saltHex, sizeof(saltHex), diff --git a/examples/fabric-sync/admin/FabricAdmin.h b/examples/fabric-sync/admin/FabricAdmin.h index 8f6d68c90a8ba2..1219e594fa8c5f 100644 --- a/examples/fabric-sync/admin/FabricAdmin.h +++ b/examples/fabric-sync/admin/FabricAdmin.h @@ -43,8 +43,8 @@ class FabricAdmin final : public bridge::FabricAdminDelegate static FabricAdmin & Instance(); CHIP_ERROR - CommissionNode(chip::Controller::CommissioningWindowPasscodeParams params, chip::VendorId vendorId, - uint16_t productId) override; + CommissionRemoteBridge(chip::Controller::CommissioningWindowPasscodeParams params, chip::VendorId vendorId, + uint16_t productId) override; CHIP_ERROR KeepActive(chip::ScopedNodeId scopedNodeId, uint32_t stayActiveDurationMs, uint32_t timeoutMs) override; diff --git a/examples/fabric-sync/bridge/include/FabricAdminDelegate.h b/examples/fabric-sync/bridge/include/FabricAdminDelegate.h index 55a145bd93d5eb..8b67ffd5b29ed7 100644 --- a/examples/fabric-sync/bridge/include/FabricAdminDelegate.h +++ b/examples/fabric-sync/bridge/include/FabricAdminDelegate.h @@ -31,9 +31,9 @@ class FabricAdminDelegate virtual ~FabricAdminDelegate() = default; /** - * Commission a node using the specified parameters. + * Reverse commission a bridge using the specified parameters. * - * This function initiates the commissioning process for a node, utilizing + * This function initiates the commissioning process for a bridge node, utilizing * the provided passcode parameters, vendor ID, and product ID. * * @param params Parameters required for commissioning the device using passcode. @@ -46,8 +46,8 @@ class FabricAdminDelegate * - CHIP_NO_ERROR: The RPC command was successfully sent and the commissioning process was initiated. * - CHIP_ERROR_INTERNAL: An internal error occurred during the preparation or sending of the command. */ - virtual CHIP_ERROR CommissionNode(chip::Controller::CommissioningWindowPasscodeParams params, chip::VendorId vendorId, - uint16_t productId) = 0; + virtual CHIP_ERROR CommissionRemoteBridge(chip::Controller::CommissioningWindowPasscodeParams params, chip::VendorId vendorId, + uint16_t productId) = 0; virtual CHIP_ERROR KeepActive(chip::ScopedNodeId scopedNodeId, uint32_t stayActiveDurationMs, uint32_t timeoutMs) = 0; }; diff --git a/examples/fabric-sync/bridge/src/CommissionerControlDelegate.cpp b/examples/fabric-sync/bridge/src/CommissionerControlDelegate.cpp index b7cc08c7e1cdfc..12851177bcb212 100644 --- a/examples/fabric-sync/bridge/src/CommissionerControlDelegate.cpp +++ b/examples/fabric-sync/bridge/src/CommissionerControlDelegate.cpp @@ -183,14 +183,14 @@ CHIP_ERROR CommissionerControlDelegate::HandleCommissionNode(const Commissioning VerifyOrReturnError(mNextStep == Step::kStartCommissionNode, CHIP_ERROR_INCORRECT_STATE); - // Attempt to commission the node using provided commissioning parameters. - err = mFabricAdmin->CommissionNode(Controller::CommissioningWindowPasscodeParams() - .SetSetupPIN(kSetupPinCode) - .SetTimeout(params.commissioningTimeout) - .SetDiscriminator(params.discriminator) - .SetIteration(params.iterations) - .SetSalt(params.salt), - mVendorId, mProductId); + // Attempt to reverse commission the bridge using provided commissioning parameters. + err = mFabricAdmin->CommissionRemoteBridge(Controller::CommissioningWindowPasscodeParams() + .SetSetupPIN(kSetupPinCode) + .SetTimeout(params.commissioningTimeout) + .SetDiscriminator(params.discriminator) + .SetIteration(params.iterations) + .SetSalt(params.salt), + mVendorId, mProductId); if (err != CHIP_NO_ERROR) { diff --git a/examples/fabric-sync/shell/AddBridgeCommand.cpp b/examples/fabric-sync/shell/AddBridgeCommand.cpp index ec6554ee72fdb0..3154b520d4d3b3 100644 --- a/examples/fabric-sync/shell/AddBridgeCommand.cpp +++ b/examples/fabric-sync/shell/AddBridgeCommand.cpp @@ -84,6 +84,9 @@ CHIP_ERROR AddBridgeCommand::RunCommand() admin::PairingManager::Instance().SetPairingDelegate(this); + ChipLogProgress(NotSpecified, "Running AddBridgeCommand with Node ID: %lu, PIN Code: %u, Address: %s, Port: %u", mBridgeNodeId, + mSetupPINCode, mRemoteAddr, mRemotePort); + return admin::DeviceMgr().PairRemoteFabricBridge(mBridgeNodeId, mSetupPINCode, mRemoteAddr, mRemotePort); } diff --git a/examples/fabric-sync/shell/AddDeviceCommand.cpp b/examples/fabric-sync/shell/AddDeviceCommand.cpp index 218691e74401ea..a85de7695deb98 100644 --- a/examples/fabric-sync/shell/AddDeviceCommand.cpp +++ b/examples/fabric-sync/shell/AddDeviceCommand.cpp @@ -71,6 +71,9 @@ CHIP_ERROR AddDeviceCommand::RunCommand() return CHIP_ERROR_INVALID_ARGUMENT; } + ChipLogProgress(NotSpecified, "Running AddDeviceCommand with Node ID: %lu, PIN Code: %u, Address: %s, Port: %u", mNodeId, + mSetupPINCode, mRemoteAddr, mRemotePort); + admin::PairingManager::Instance().SetPairingDelegate(this); return admin::DeviceMgr().PairRemoteDevice(mNodeId, mSetupPINCode, mRemoteAddr, mRemotePort); diff --git a/examples/fabric-sync/shell/RemoveBridgeCommand.cpp b/examples/fabric-sync/shell/RemoveBridgeCommand.cpp index 2eaaf6fc34476f..3b886f8e6ad3ab 100644 --- a/examples/fabric-sync/shell/RemoveBridgeCommand.cpp +++ b/examples/fabric-sync/shell/RemoveBridgeCommand.cpp @@ -62,6 +62,8 @@ CHIP_ERROR RemoveBridgeCommand::RunCommand() mBridgeNodeId = bridgeNodeId; + ChipLogProgress(NotSpecified, "Running RemoveBridgeCommand"); + admin::PairingManager::Instance().SetPairingDelegate(this); return admin::DeviceMgr().UnpairRemoteFabricBridge(); diff --git a/examples/fabric-sync/shell/RemoveDeviceCommand.cpp b/examples/fabric-sync/shell/RemoveDeviceCommand.cpp index 266a2ad1065569..78440f854283aa 100644 --- a/examples/fabric-sync/shell/RemoveDeviceCommand.cpp +++ b/examples/fabric-sync/shell/RemoveDeviceCommand.cpp @@ -61,6 +61,8 @@ CHIP_ERROR RemoveDeviceCommand::RunCommand() admin::PairingManager::Instance().SetPairingDelegate(this); + ChipLogProgress(NotSpecified, "Running RemoveDeviceCommand with Node ID: %lu", mNodeId); + return admin::DeviceMgr().UnpairRemoteDevice(mNodeId); } diff --git a/examples/fabric-sync/shell/ShellCommands.cpp b/examples/fabric-sync/shell/ShellCommands.cpp index 008684e66c1b66..3bab442aa5fc47 100644 --- a/examples/fabric-sync/shell/ShellCommands.cpp +++ b/examples/fabric-sync/shell/ShellCommands.cpp @@ -133,7 +133,7 @@ static CHIP_ERROR HandleAddDeviceCommand(int argc, char ** argv) const char * remoteAddr = argv[3]; uint16_t remotePort = static_cast(strtoul(argv[4], nullptr, 10)); - auto command = std::make_unique(nodeId, setupPINCode, remoteAddr, remotePort); + auto command = std::make_unique(nodeId, setupPINCode, remoteAddr, remotePort); CHIP_ERROR result = command->RunCommand(); if (result == CHIP_NO_ERROR) @@ -215,7 +215,6 @@ void RegisterCommands() // Register the root `device` command with the top-level shell. Engine::Root().RegisterCommands(&sDeviceComand, 1); - return; } } // namespace Shell