diff --git a/examples/fabric-admin/BUILD.gn b/examples/fabric-admin/BUILD.gn index ad7eb217f9914c..4db5cb9040ad4b 100644 --- a/examples/fabric-admin/BUILD.gn +++ b/examples/fabric-admin/BUILD.gn @@ -61,6 +61,8 @@ static_library("fabric-admin-utils") { "${chip_root}/zzz_generated/chip-tool/zap-generated/cluster/logging/DataModelLogger.cpp", "commands/clusters/ModelCommand.cpp", "commands/clusters/ModelCommand.h", + "commands/clusters/ReportCommand.cpp", + "commands/clusters/ReportCommand.h", "commands/common/CHIPCommand.cpp", "commands/common/CHIPCommand.h", "commands/common/Command.cpp", diff --git a/examples/fabric-admin/commands/clusters/ReportCommand.cpp b/examples/fabric-admin/commands/clusters/ReportCommand.cpp new file mode 100644 index 00000000000000..b89ec0809433bc --- /dev/null +++ b/examples/fabric-admin/commands/clusters/ReportCommand.cpp @@ -0,0 +1,80 @@ +/* + * Copyright (c) 2024 Project CHIP Authors + * All rights reserved. + * + * Licensed under the Apache License, Version 2.0 (the "License"); + * you may not use this file except in compliance with the License. + * You may obtain a copy of the License at + * + * http://www.apache.org/licenses/LICENSE-2.0 + * + * Unless required by applicable law or agreed to in writing, software + * distributed under the License is distributed on an "AS IS" BASIS, + * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. + * See the License for the specific language governing permissions and + * limitations under the License. + * + */ + +#include "ReportCommand.h" + +#include +#include + +using namespace ::chip; + +void ReportCommand::OnAttributeData(const app::ConcreteDataAttributePath & path, TLV::TLVReader * data, + const app::StatusIB & status) +{ + CHIP_ERROR error = status.ToChipError(); + if (CHIP_NO_ERROR != error) + { + LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); + + ChipLogError(NotSpecified, "Response Failure: %s", ErrorStr(error)); + mError = error; + return; + } + + if (data == nullptr) + { + ChipLogError(NotSpecified, "Response Failure: No Data"); + mError = CHIP_ERROR_INTERNAL; + return; + } + + LogErrorOnFailure(RemoteDataModelLogger::LogAttributeAsJSON(path, data)); +} + +void ReportCommand::OnEventData(const app::EventHeader & eventHeader, TLV::TLVReader * data, const app::StatusIB * status) +{ + if (status != nullptr) + { + CHIP_ERROR error = status->ToChipError(); + if (CHIP_NO_ERROR != error) + { + LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(eventHeader, *status)); + + ChipLogError(NotSpecified, "Response Failure: %s", ErrorStr(error)); + mError = error; + return; + } + } + + if (data == nullptr) + { + ChipLogError(NotSpecified, "Response Failure: No Data"); + mError = CHIP_ERROR_INTERNAL; + return; + } + + LogErrorOnFailure(RemoteDataModelLogger::LogEventAsJSON(eventHeader, data)); + + CHIP_ERROR error = DataModelLogger::LogEvent(eventHeader, data); + if (CHIP_NO_ERROR != error) + { + ChipLogError(NotSpecified, "Response Failure: Can not decode Data"); + mError = error; + return; + } +} diff --git a/examples/fabric-admin/commands/clusters/ReportCommand.h b/examples/fabric-admin/commands/clusters/ReportCommand.h index 4e9dbd0f043931..f92cc4de554545 100644 --- a/examples/fabric-admin/commands/clusters/ReportCommand.h +++ b/examples/fabric-admin/commands/clusters/ReportCommand.h @@ -32,69 +32,10 @@ class ReportCommand : public InteractionModelReports, public ModelCommand, publi /////////// ReadClient Callback Interface ///////// void OnAttributeData(const chip::app::ConcreteDataAttributePath & path, chip::TLV::TLVReader * data, - const chip::app::StatusIB & status) override - { - CHIP_ERROR error = status.ToChipError(); - if (CHIP_NO_ERROR != error) - { - LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(path, status)); - - ChipLogError(NotSpecified, "Response Failure: %s", chip::ErrorStr(error)); - mError = error; - return; - } - - if (data == nullptr) - { - ChipLogError(NotSpecified, "Response Failure: No Data"); - mError = CHIP_ERROR_INTERNAL; - return; - } - - LogErrorOnFailure(RemoteDataModelLogger::LogAttributeAsJSON(path, data)); - - error = DataModelLogger::LogAttribute(path, data); - if (CHIP_NO_ERROR != error) - { - ChipLogError(NotSpecified, "Response Failure: Can not decode Data"); - mError = error; - return; - } - } + const chip::app::StatusIB & status) override; void OnEventData(const chip::app::EventHeader & eventHeader, chip::TLV::TLVReader * data, - const chip::app::StatusIB * status) override - { - if (status != nullptr) - { - CHIP_ERROR error = status->ToChipError(); - if (CHIP_NO_ERROR != error) - { - LogErrorOnFailure(RemoteDataModelLogger::LogErrorAsJSON(eventHeader, *status)); - - ChipLogError(NotSpecified, "Response Failure: %s", chip::ErrorStr(error)); - mError = error; - return; - } - } - - if (data == nullptr) - { - ChipLogError(NotSpecified, "Response Failure: No Data"); - mError = CHIP_ERROR_INTERNAL; - return; - } - - LogErrorOnFailure(RemoteDataModelLogger::LogEventAsJSON(eventHeader, data)); - - CHIP_ERROR error = DataModelLogger::LogEvent(eventHeader, data); - if (CHIP_NO_ERROR != error) - { - ChipLogError(NotSpecified, "Response Failure: Can not decode Data"); - mError = error; - return; - } - } + const chip::app::StatusIB * status) override; void OnError(CHIP_ERROR error) override { diff --git a/examples/fabric-admin/commands/common/Commands.cpp b/examples/fabric-admin/commands/common/Commands.cpp index 3742978443796a..3bcd04e425345e 100644 --- a/examples/fabric-admin/commands/common/Commands.cpp +++ b/examples/fabric-admin/commands/common/Commands.cpp @@ -150,6 +150,9 @@ static void DetectAndLogMismatchedDoubleQuotes(int argc, char ** argv) } // namespace +// Define the static member +Commands Commands::sInstance; + void Commands::Register(const char * commandSetName, commands_list commandsList, const char * helpText, bool isCluster) { VerifyOrDieWithMsg(isCluster || helpText != nullptr, NotSpecified, "Non-cluster command sets must have help text"); @@ -337,6 +340,7 @@ Commands::CommandSetMap::iterator Commands::GetCommandSet(std::string commandSet { std::string key(commandSet.first); std::transform(key.begin(), key.end(), key.begin(), ::tolower); + if (key.compare(commandSetName) == 0) { return mCommandSets.find(commandSet.first); @@ -346,6 +350,23 @@ Commands::CommandSetMap::iterator Commands::GetCommandSet(std::string commandSet return mCommandSets.end(); } +Command * Commands::GetCommandByName(std::string commandSetName, std::string commandName) +{ + auto commandSetIter = GetCommandSet(commandSetName); + if (commandSetIter != mCommandSets.end()) + { + auto & commandList = commandSetIter->second.commands; + for (auto & command : commandList) + { + if (command->GetName() == commandName) + { + return command.get(); + } + } + } + return nullptr; +} + Command * Commands::GetCommand(CommandsVector & commands, std::string commandName) { for (auto & command : commands) diff --git a/examples/fabric-admin/commands/common/Commands.h b/examples/fabric-admin/commands/common/Commands.h index 8638ededcb3b8c..f071ac08c45873 100644 --- a/examples/fabric-admin/commands/common/Commands.h +++ b/examples/fabric-admin/commands/common/Commands.h @@ -45,6 +45,8 @@ class Commands int Run(int argc, char ** argv); int RunInteractive(const char * command, const chip::Optional & storageDirectory, bool advertiseOperational); + Command * GetCommandByName(std::string commandSetName, std::string commandName); + private: struct CommandSet { @@ -87,4 +89,18 @@ class Commands #ifdef CONFIG_USE_LOCAL_STORAGE PersistentStorage mStorage; #endif // CONFIG_USE_LOCAL_STORAGE + + friend Commands & CommandMgr(); + static Commands sInstance; }; + +/** + * Returns the public interface of the CommandManager singleton object. + * + * Applications should use this to access features of the CommandManager + * object. + */ +inline Commands & CommandMgr() +{ + return Commands::sInstance; +} diff --git a/examples/fabric-admin/commands/fabric-sync/Commands.h b/examples/fabric-admin/commands/fabric-sync/Commands.h index f2be577065b617..f277c28f9d15b4 100644 --- a/examples/fabric-admin/commands/fabric-sync/Commands.h +++ b/examples/fabric-admin/commands/fabric-sync/Commands.h @@ -27,6 +27,7 @@ void registerCommandsFabricSync(Commands & commands, CredentialIssuerCommands * commands_list clusterCommands = { 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 38ea541dab5873..381dc50c83018b 100644 --- a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp +++ b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp @@ -18,6 +18,8 @@ #include "FabricSyncCommand.h" #include +#include +#include #include #include @@ -27,6 +29,16 @@ using namespace ::chip; +namespace { + +// Constants +constexpr uint32_t kCommissionPrepareTimeMs = 500; +constexpr uint16_t kMaxManaulCodeLength = 21; +constexpr uint16_t kSubscribeMinInterval = 0; +constexpr uint16_t kSubscribeMaxInterval = 60; + +} // namespace + CHIP_ERROR FabricSyncAddDeviceCommand::RunCommand(NodeId remoteId) { #if defined(PW_RPC_ENABLED) @@ -36,3 +48,86 @@ CHIP_ERROR FabricSyncAddDeviceCommand::RunCommand(NodeId remoteId) return CHIP_ERROR_NOT_IMPLEMENTED; #endif } + +void FabricSyncDeviceCommand::OnCommissioningWindowOpened(NodeId deviceId, CHIP_ERROR err, chip::SetupPayload payload) +{ + if (err == CHIP_NO_ERROR) + { + char payloadBuffer[kMaxManaulCodeLength + 1]; + MutableCharSpan manualCode(payloadBuffer); + CHIP_ERROR error = ManualSetupPayloadGenerator(payload).payloadDecimalStringRepresentation(manualCode); + if (error == CHIP_NO_ERROR) + { + char command[kMaxCommandSize]; + NodeId nodeId = 2; // TODO: (Issue #33947) need to switch to dynamically assigned ID + snprintf(command, sizeof(command), "pairing code %ld %s", nodeId, payloadBuffer); + + PairingCommand * pairingCommand = static_cast(CommandMgr().GetCommandByName("pairing", "code")); + + if (pairingCommand == nullptr) + { + ChipLogError(NotSpecified, "Pairing code command is not available"); + return; + } + + pairingCommand->RegisterCommissioningDelegate(this); + mAssignedNodeId = nodeId; + + usleep(kCommissionPrepareTimeMs * 1000); + + PushCommand(command); + } + else + { + ChipLogError(NotSpecified, "Unable to generate manual code for setup payload: %" CHIP_ERROR_FORMAT, error.Format()); + } + } + else + { + ChipLogError(NotSpecified, + "Failed to open synced device (0x:" ChipLogFormatX64 ") commissioning window: %" CHIP_ERROR_FORMAT, + ChipLogValueX64(deviceId), err.Format()); + } +} + +void FabricSyncDeviceCommand::OnCommissioningComplete(chip::NodeId deviceId, CHIP_ERROR err) +{ + if (mAssignedNodeId != deviceId) + { + // Ignore if the deviceId does not match the mAssignedNodeId. + // This scenario should not occur because no other device should be commissioned during the fabric sync process. + return; + } + + if (err == CHIP_NO_ERROR) + { + // TODO: (Issue #33947) Add Synced Device to device manager + } + else + { + ChipLogError(NotSpecified, "Failed to pair synced device (0x:" ChipLogFormatX64 ") with error: %" CHIP_ERROR_FORMAT, + ChipLogValueX64(deviceId), err.Format()); + } +} + +CHIP_ERROR FabricSyncDeviceCommand::RunCommand(EndpointId remoteId) +{ + char command[kMaxCommandSize]; + NodeId bridgeNodeId = 1; // TODO: (Issue #33947) need to switch to configured ID + snprintf(command, sizeof(command), "pairing open-commissioning-window %ld %d %d %d %d %d", bridgeNodeId, remoteId, + kEnhancedCommissioningMethod, kWindowTimeout, kIteration, kDiscriminator); + + OpenCommissioningWindowCommand * openCommand = + static_cast(CommandMgr().GetCommandByName("pairing", "open-commissioning-window")); + + if (openCommand == nullptr) + { + return CHIP_ERROR_UNINITIALIZED; + } + + openCommand->RegisterDelegate(this); + + PushCommand(command); + + 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 cf739ccfb3a520..7b8f6f938afec9 100644 --- a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h +++ b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h @@ -19,6 +19,14 @@ #pragma once #include +#include +#include + +constexpr uint16_t kMaxCommandSize = 64; +constexpr uint16_t kDiscriminator = 3840; +constexpr uint16_t kWindowTimeout = 300; +constexpr uint16_t kIteration = 1000; +constexpr uint8_t kEnhancedCommissioningMethod = 1; class FabricSyncAddDeviceCommand : public CHIPCommand { @@ -38,3 +46,26 @@ class FabricSyncAddDeviceCommand : public CHIPCommand CHIP_ERROR RunCommand(NodeId remoteId); }; + +class FabricSyncDeviceCommand : public CHIPCommand, public CommissioningWindowDelegate, public CommissioningDelegate +{ +public: + FabricSyncDeviceCommand(CredentialIssuerCommands * credIssuerCommands) : CHIPCommand("sync-device", credIssuerCommands) + { + 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; + + /////////// CHIPCommand Interface ///////// + CHIP_ERROR RunCommand() override { return RunCommand(mRemoteEndpointId); } + + chip::System::Clock::Timeout GetWaitDuration() const override { return chip::System::Clock::Seconds16(1); } + +private: + chip::EndpointId mRemoteEndpointId = chip::kInvalidEndpointId; + chip::NodeId mAssignedNodeId = chip::kUndefinedNodeId; + + CHIP_ERROR RunCommand(chip::EndpointId remoteId); +}; diff --git a/examples/fabric-admin/commands/interactive/InteractiveCommands.cpp b/examples/fabric-admin/commands/interactive/InteractiveCommands.cpp index 4b767c460c1f87..cd63510ab2215e 100644 --- a/examples/fabric-admin/commands/interactive/InteractiveCommands.cpp +++ b/examples/fabric-admin/commands/interactive/InteractiveCommands.cpp @@ -149,8 +149,6 @@ char * InteractiveStartCommand::GetCommand(char * command) command = new char[cmd.length() + 1]; strcpy(command, cmd.c_str()); - ChipLogProgress(NotSpecified, "GetCommand: %s", command); - // Do not save empty lines if (command != nullptr && *command) { diff --git a/examples/fabric-admin/commands/pairing/OpenCommissioningWindowCommand.cpp b/examples/fabric-admin/commands/pairing/OpenCommissioningWindowCommand.cpp index bc4af6c4a51cec..93d1f6f51002f8 100644 --- a/examples/fabric-admin/commands/pairing/OpenCommissioningWindowCommand.cpp +++ b/examples/fabric-admin/commands/pairing/OpenCommissioningWindowCommand.cpp @@ -47,8 +47,14 @@ CHIP_ERROR OpenCommissioningWindowCommand::RunCommand() void OpenCommissioningWindowCommand::OnOpenCommissioningWindowResponse(void * context, NodeId remoteId, CHIP_ERROR err, chip::SetupPayload payload) { - LogErrorOnFailure(err); + OpenCommissioningWindowCommand * self = static_cast(context); + if (self->mDelegate) + { + self->mDelegate->OnCommissioningWindowOpened(remoteId, err, payload); + self->UnregisterDelegate(); + } + LogErrorOnFailure(err); OnOpenBasicCommissioningWindowResponse(context, remoteId, err); } diff --git a/examples/fabric-admin/commands/pairing/OpenCommissioningWindowCommand.h b/examples/fabric-admin/commands/pairing/OpenCommissioningWindowCommand.h index 5bf6fd986f1947..86e1b68c3d5f3f 100644 --- a/examples/fabric-admin/commands/pairing/OpenCommissioningWindowCommand.h +++ b/examples/fabric-admin/commands/pairing/OpenCommissioningWindowCommand.h @@ -22,6 +22,13 @@ #include #include +class CommissioningWindowDelegate +{ +public: + virtual void OnCommissioningWindowOpened(chip::NodeId deviceId, CHIP_ERROR err, chip::SetupPayload payload) = 0; + virtual ~CommissioningWindowDelegate() = default; +}; + class OpenCommissioningWindowCommand : public CHIPCommand { public: @@ -31,6 +38,7 @@ class OpenCommissioningWindowCommand : public CHIPCommand mOnOpenBasicCommissioningWindowCallback(OnOpenBasicCommissioningWindowResponse, this) { AddArgument("node-id", 0, UINT64_MAX, &mNodeId, "Node to send command to."); + AddArgument("endpoint-id", 0, UINT16_MAX, &mEndpointId, "Endpoint to send command to."); AddArgument("option", 0, 2, &mCommissioningWindowOption, "1 to use Enhanced Commissioning Method.\n 0 to use Basic Commissioning Method."); AddArgument("window-timeout", 0, UINT16_MAX, &mCommissioningWindowTimeout, @@ -41,6 +49,9 @@ class OpenCommissioningWindowCommand : public CHIPCommand AddArgument("timeout", 0, UINT16_MAX, &mTimeout, "Time, in seconds, before this command is considered to have timed out."); } + void RegisterDelegate(CommissioningWindowDelegate * delegate) { mDelegate = delegate; } + void UnregisterDelegate() { mDelegate = nullptr; } + /////////// CHIPCommand Interface ///////// CHIP_ERROR RunCommand() override; @@ -50,7 +61,9 @@ class OpenCommissioningWindowCommand : public CHIPCommand private: NodeId mNodeId; + chip::EndpointId mEndpointId; chip::Controller::CommissioningWindowOpener::CommissioningWindowOption mCommissioningWindowOption; + CommissioningWindowDelegate * mDelegate = nullptr; uint16_t mCommissioningWindowTimeout; uint32_t mIteration; uint16_t mDiscriminator; diff --git a/examples/fabric-admin/commands/pairing/PairingCommand.cpp b/examples/fabric-admin/commands/pairing/PairingCommand.cpp index 92754c2adaa69a..8a261b01a8865b 100644 --- a/examples/fabric-admin/commands/pairing/PairingCommand.cpp +++ b/examples/fabric-admin/commands/pairing/PairingCommand.cpp @@ -30,6 +30,10 @@ #include +#if defined(PW_RPC_ENABLED) +#include +#endif + using namespace ::chip; using namespace ::chip::Controller; @@ -389,7 +393,12 @@ void PairingCommand::OnCommissioningComplete(NodeId nodeId, CHIP_ERROR err) { if (err == CHIP_NO_ERROR) { - ChipLogProgress(NotSpecified, "Device commissioning completed with success"); + // print to console + fprintf(stderr, "New device with Node ID: 0x%lx has been successfully added.\n", nodeId); + +#if defined(PW_RPC_ENABLED) + AddSynchronizedDevice(nodeId); +#endif } else { @@ -406,6 +415,12 @@ void PairingCommand::OnCommissioningComplete(NodeId nodeId, CHIP_ERROR err) ChipLogProgress(NotSpecified, "Device commissioning Failure: %s", ErrorStr(err)); } + if (mCommissioningDelegate) + { + mCommissioningDelegate->OnCommissioningComplete(nodeId, err); + this->UnregisterCommissioningDelegate(); + } + SetCommandExitStatus(err); } @@ -520,13 +535,25 @@ void PairingCommand::OnCurrentFabricRemove(void * context, NodeId nodeId, CHIP_E if (err == CHIP_NO_ERROR) { - ChipLogProgress(NotSpecified, "Device unpair completed with success: " ChipLogFormatX64, ChipLogValueX64(nodeId)); + // print to console + fprintf(stderr, "Device with Node ID: 0x%lx has been successfully removed.\n", nodeId); + +#if defined(PW_RPC_ENABLED) + RemoveSynchronizedDevice(nodeId); +#endif } else { ChipLogProgress(NotSpecified, "Device unpair Failure: " ChipLogFormatX64 " %s", ChipLogValueX64(nodeId), ErrorStr(err)); } + PairingDelegate * pairingDelegate = command->GetPairingDelegate(); + if (pairingDelegate) + { + pairingDelegate->OnDeviceRemoved(nodeId, err); + command->UnregisterPairingDelegate(); + } + command->SetCommandExitStatus(err); } diff --git a/examples/fabric-admin/commands/pairing/PairingCommand.h b/examples/fabric-admin/commands/pairing/PairingCommand.h index 331d177448aed5..fbd33440f5bb14 100644 --- a/examples/fabric-admin/commands/pairing/PairingCommand.h +++ b/examples/fabric-admin/commands/pairing/PairingCommand.h @@ -45,6 +45,20 @@ enum class PairingNetworkType Thread, }; +class CommissioningDelegate +{ +public: + virtual void OnCommissioningComplete(chip::NodeId deviceId, CHIP_ERROR err) = 0; + virtual ~CommissioningDelegate() = default; +}; + +class PairingDelegate +{ +public: + virtual void OnDeviceRemoved(chip::NodeId deviceId, CHIP_ERROR err) = 0; + virtual ~PairingDelegate() = default; +}; + class PairingCommand : public CHIPCommand, public chip::Controller::DevicePairingDelegate, public chip::Controller::DeviceDiscoveryDelegate, @@ -73,6 +87,7 @@ class PairingCommand : public CHIPCommand, AddArgument("icd-symmetric-key", &mICDSymmetricKey, "The 16 bytes ICD symmetric key, default: randomly generated."); AddArgument("icd-stay-active-duration", 0, UINT32_MAX, &mICDStayActiveDurationMsec, "If set, a LIT ICD that is commissioned will be requested to stay active for this many milliseconds"); + switch (networkType) { case PairingNetworkType::None: @@ -202,12 +217,21 @@ class PairingCommand : public CHIPCommand, /////////// DeviceDiscoveryDelegate Interface ///////// void OnDiscoveredDevice(const chip::Dnssd::CommissionNodeData & nodeData) override; - /////////// DeviceAttestationDelegate ///////// + /////////// DeviceAttestationDelegate Interface ///////// chip::Optional FailSafeExpiryTimeoutSecs() const override; void OnDeviceAttestationCompleted(chip::Controller::DeviceCommissioner * deviceCommissioner, chip::DeviceProxy * device, const chip::Credentials::DeviceAttestationVerifier::AttestationDeviceInfo & info, chip::Credentials::AttestationVerificationResult attestationResult) override; + /////////// CommissioningDelegate ///////// + void RegisterCommissioningDelegate(CommissioningDelegate * delegate) { mCommissioningDelegate = delegate; } + void UnregisterCommissioningDelegate() { mCommissioningDelegate = nullptr; } + + /////////// PairingDelegate ///////// + void RegisterPairingDelegate(PairingDelegate * delegate) { mPairingDelegate = delegate; } + void UnregisterPairingDelegate() { mPairingDelegate = nullptr; } + PairingDelegate * GetPairingDelegate() { return mPairingDelegate; } + private: CHIP_ERROR RunInternal(NodeId remoteId); CHIP_ERROR Pair(NodeId remoteId, PeerAddress address); @@ -262,6 +286,9 @@ class PairingCommand : public CHIPCommand, chip::Platform::UniquePtr mCurrentFabricRemover; chip::Callback::Callback mCurrentFabricRemoveCallback; + CommissioningDelegate * mCommissioningDelegate = nullptr; + PairingDelegate * mPairingDelegate = nullptr; + static void OnCurrentFabricRemove(void * context, NodeId remoteNodeId, CHIP_ERROR status); void PersistIcdInfo(); }; diff --git a/examples/fabric-admin/main.cpp b/examples/fabric-admin/main.cpp index f5f98cc0d960db..d85578f784c293 100644 --- a/examples/fabric-admin/main.cpp +++ b/examples/fabric-admin/main.cpp @@ -58,7 +58,7 @@ int main(int argc, char * argv[]) } ExampleCredentialIssuerCommands credIssuerCommands; - Commands commands; + Commands & commands = CommandMgr(); registerCommandsFabricSync(commands, &credIssuerCommands); registerCommandsInteractive(commands, &credIssuerCommands); diff --git a/examples/fabric-admin/rpc/RpcClient.cpp b/examples/fabric-admin/rpc/RpcClient.cpp index a1a34d309ba17a..96a39e91f23b02 100644 --- a/examples/fabric-admin/rpc/RpcClient.cpp +++ b/examples/fabric-admin/rpc/RpcClient.cpp @@ -25,7 +25,6 @@ #include "fabric_bridge_service/fabric_bridge_service.rpc.pb.h" #include "pw_assert/check.h" -#include "pw_function/function.h" #include "pw_hdlc/decoder.h" #include "pw_hdlc/default_addresses.h" #include "pw_hdlc/rpc_channel.h" @@ -70,7 +69,7 @@ CHIP_ERROR AddSynchronizedDevice(chip::NodeId nodeId) if (addSynchronizedDeviceCall.active()) { - ChipLogError(NotSpecified, "OpenCommissioningWindow is in progress\n"); + ChipLogError(NotSpecified, "Add Synchronized Device operation is in progress\n"); return CHIP_ERROR_BUSY; } diff --git a/examples/fabric-admin/rpc/RpcClient.h b/examples/fabric-admin/rpc/RpcClient.h index efe3c24acc3b23..f6ce805d607ce0 100644 --- a/examples/fabric-admin/rpc/RpcClient.h +++ b/examples/fabric-admin/rpc/RpcClient.h @@ -36,7 +36,7 @@ CHIP_ERROR InitRpcClient(uint16_t rpcServerPort); * @brief Adds a synchronized device to the RPC client. * * This function attempts to add a device identified by its `nodeId` to the synchronized device list. - * It logs the progress and checks if an `OpenCommissioningWindow` operation is already in progress. + * It logs the progress and checks if an `AddSynchronizedDevice` operation is already in progress. * If an operation is in progress, it returns `CHIP_ERROR_BUSY`. * * @param nodeId The Node ID of the device to be added.