Skip to content

Commit

Permalink
Add debug log
Browse files Browse the repository at this point in the history
  • Loading branch information
yufengwangca committed Nov 12, 2024
1 parent 641726e commit 73fb325
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 17 deletions.
2 changes: 1 addition & 1 deletion examples/fabric-sync/admin/FabricAdmin.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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),
Expand Down
4 changes: 2 additions & 2 deletions examples/fabric-sync/admin/FabricAdmin.h
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down
8 changes: 4 additions & 4 deletions examples/fabric-sync/bridge/include/FabricAdminDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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;
};
Expand Down
16 changes: 8 additions & 8 deletions examples/fabric-sync/bridge/src/CommissionerControlDelegate.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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)
{
Expand Down
3 changes: 3 additions & 0 deletions examples/fabric-sync/shell/AddBridgeCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 3 additions & 0 deletions examples/fabric-sync/shell/AddDeviceCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
2 changes: 2 additions & 0 deletions examples/fabric-sync/shell/RemoveBridgeCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ CHIP_ERROR RemoveBridgeCommand::RunCommand()

mBridgeNodeId = bridgeNodeId;

ChipLogProgress(NotSpecified, "Running RemoveBridgeCommand");

admin::PairingManager::Instance().SetPairingDelegate(this);

return admin::DeviceMgr().UnpairRemoteFabricBridge();
Expand Down
2 changes: 2 additions & 0 deletions examples/fabric-sync/shell/RemoveDeviceCommand.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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);
}

Expand Down
3 changes: 1 addition & 2 deletions examples/fabric-sync/shell/ShellCommands.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -133,7 +133,7 @@ static CHIP_ERROR HandleAddDeviceCommand(int argc, char ** argv)
const char * remoteAddr = argv[3];
uint16_t remotePort = static_cast<uint16_t>(strtoul(argv[4], nullptr, 10));

auto command = std::make_unique<commands::AddBridgeCommand>(nodeId, setupPINCode, remoteAddr, remotePort);
auto command = std::make_unique<commands::AddDeviceCommand>(nodeId, setupPINCode, remoteAddr, remotePort);

CHIP_ERROR result = command->RunCommand();
if (result == CHIP_NO_ERROR)
Expand Down Expand Up @@ -215,7 +215,6 @@ void RegisterCommands()

// Register the root `device` command with the top-level shell.
Engine::Root().RegisterCommands(&sDeviceComand, 1);
return;
}

} // namespace Shell
Expand Down

0 comments on commit 73fb325

Please sign in to comment.