Put fabric sync logic into namespace admin (#36361)
diff --git a/examples/fabric-admin/commands/common/CHIPCommand.cpp b/examples/fabric-admin/commands/common/CHIPCommand.cpp
index c23ea82..e7f4071 100644
--- a/examples/fabric-admin/commands/common/CHIPCommand.cpp
+++ b/examples/fabric-admin/commands/common/CHIPCommand.cpp
@@ -182,7 +182,7 @@
mCredIssuerCmds->SetCredentialIssuerOption(CredentialIssuerCommands::CredentialIssuerOptions::kAllowTestCdSigningKey,
allowTestCdSigningKey);
- ReturnLogErrorOnFailure(PairingManager::Instance().Init(&CurrentCommissioner(), mCredIssuerCmds));
+ ReturnLogErrorOnFailure(admin::PairingManager::Instance().Init(&CurrentCommissioner(), mCredIssuerCmds));
return CHIP_NO_ERROR;
}
diff --git a/examples/fabric-admin/commands/fabric-sync/Commands.h b/examples/fabric-admin/commands/fabric-sync/Commands.h
index 47f7207..0f2f3f6 100644
--- a/examples/fabric-admin/commands/fabric-sync/Commands.h
+++ b/examples/fabric-admin/commands/fabric-sync/Commands.h
@@ -26,11 +26,11 @@
const char * clusterName = "FabricSync";
commands_list clusterCommands = {
- make_unique<FabricSyncAddBridgeCommand>(credsIssuerConfig),
- make_unique<FabricSyncRemoveBridgeCommand>(credsIssuerConfig),
- make_unique<FabricSyncAddLocalBridgeCommand>(credsIssuerConfig),
- make_unique<FabricSyncRemoveLocalBridgeCommand>(credsIssuerConfig),
- make_unique<FabricSyncDeviceCommand>(credsIssuerConfig),
+ make_unique<admin::FabricSyncAddBridgeCommand>(credsIssuerConfig),
+ make_unique<admin::FabricSyncRemoveBridgeCommand>(credsIssuerConfig),
+ make_unique<admin::FabricSyncAddLocalBridgeCommand>(credsIssuerConfig),
+ make_unique<admin::FabricSyncRemoveLocalBridgeCommand>(credsIssuerConfig),
+ make_unique<admin::FabricSyncDeviceCommand>(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 f10db13..6d42b04 100644
--- a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp
+++ b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.cpp
@@ -30,6 +30,8 @@
using namespace ::chip;
+namespace admin {
+
void FabricSyncAddBridgeCommand::OnCommissioningComplete(NodeId deviceId, CHIP_ERROR err)
{
if (mBridgeNodeId != deviceId)
@@ -305,3 +307,5 @@
return CHIP_NO_ERROR;
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h
index 8d14529..809cc7d 100644
--- a/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h
+++ b/examples/fabric-admin/commands/fabric-sync/FabricSyncCommand.h
@@ -21,6 +21,8 @@
#include <commands/common/CHIPCommand.h>
#include <device_manager/PairingManager.h>
+namespace admin {
+
// Constants
constexpr uint32_t kCommissionPrepareTimeMs = 500;
@@ -136,3 +138,5 @@
CHIP_ERROR RunCommand(chip::EndpointId remoteId);
};
+
+} // namespace admin
diff --git a/examples/fabric-admin/commands/interactive/InteractiveCommands.cpp b/examples/fabric-admin/commands/interactive/InteractiveCommands.cpp
index 0209a78..bd35225 100644
--- a/examples/fabric-admin/commands/interactive/InteractiveCommands.cpp
+++ b/examples/fabric-admin/commands/interactive/InteractiveCommands.cpp
@@ -117,7 +117,7 @@
#if defined(PW_RPC_ENABLED)
void AttemptRpcClientConnect(System::Layer * systemLayer, void * appState)
{
- if (StartRpcClient() == CHIP_NO_ERROR)
+ if (admin::StartRpcClient() == CHIP_NO_ERROR)
{
// print to console
fprintf(stderr, "Connected to Fabric-Bridge\n");
@@ -199,8 +199,8 @@
}
#if defined(PW_RPC_ENABLED)
- SetRpcRemoteServerPort(mFabricBridgeServerPort.Value());
- InitRpcServer(mLocalServerPort.Value());
+ admin::SetRpcRemoteServerPort(mFabricBridgeServerPort.Value());
+ admin::InitRpcServer(mLocalServerPort.Value());
ChipLogProgress(NotSpecified, "PW_RPC initialized.");
DeviceLayer::PlatformMgr().ScheduleWork(ExecuteDeferredConnect, 0);
#endif
diff --git a/examples/fabric-admin/commands/pairing/PairingCommand.cpp b/examples/fabric-admin/commands/pairing/PairingCommand.cpp
index 3757847..031b57e 100644
--- a/examples/fabric-admin/commands/pairing/PairingCommand.cpp
+++ b/examples/fabric-admin/commands/pairing/PairingCommand.cpp
@@ -405,7 +405,7 @@
fprintf(stderr, "New device with Node ID: 0x%lx has been successfully added.\n", nodeId);
// CurrentCommissioner() has a lifetime that is the entire life of the application itself
// so it is safe to provide to StartDeviceSynchronization.
- DeviceSynchronizer::Instance().StartDeviceSynchronization(&CurrentCommissioner(), mNodeId, mDeviceIsICD);
+ admin::DeviceSynchronizer::Instance().StartDeviceSynchronization(&CurrentCommissioner(), mNodeId, mDeviceIsICD);
}
else
{
@@ -542,7 +542,7 @@
#if defined(PW_RPC_ENABLED)
app::InteractionModelEngine::GetInstance()->ShutdownSubscriptions(command->CurrentCommissioner().GetFabricIndex(), nodeId);
ScopedNodeId scopedNodeId(nodeId, command->CurrentCommissioner().GetFabricIndex());
- RemoveSynchronizedDevice(scopedNodeId);
+ admin::RemoveSynchronizedDevice(scopedNodeId);
#endif
}
else
diff --git a/examples/fabric-admin/device_manager/BridgeSubscription.cpp b/examples/fabric-admin/device_manager/BridgeSubscription.cpp
index 2efcada..e7052d7 100644
--- a/examples/fabric-admin/device_manager/BridgeSubscription.cpp
+++ b/examples/fabric-admin/device_manager/BridgeSubscription.cpp
@@ -17,12 +17,14 @@
*/
#include "BridgeSubscription.h"
-#include <device_manager/DeviceManager.h>
+#include "DeviceManager.h"
using namespace ::chip;
using namespace ::chip::app;
using chip::app::ReadClient;
+namespace admin {
+
namespace {
constexpr uint16_t kSubscribeMinInterval = 0;
@@ -157,3 +159,5 @@
ChipLogError(NotSpecified, "BridgeSubscription failed to connect to " ChipLogFormatX64, ChipLogValueX64(peerId.GetNodeId()));
OnDone(nullptr);
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/BridgeSubscription.h b/examples/fabric-admin/device_manager/BridgeSubscription.h
index bd2a702..e5f8c73 100644
--- a/examples/fabric-admin/device_manager/BridgeSubscription.h
+++ b/examples/fabric-admin/device_manager/BridgeSubscription.h
@@ -24,6 +24,8 @@
#include <memory>
#include <optional>
+namespace admin {
+
/**
* @brief Class used to subscribe to attributes and events from the remote bridged device.
*
@@ -75,3 +77,5 @@
chip::EndpointId mEndpointId;
bool subscriptionStarted = false;
};
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/CommissionerControl.cpp b/examples/fabric-admin/device_manager/CommissionerControl.cpp
index b919ceb..80c9437 100644
--- a/examples/fabric-admin/device_manager/CommissionerControl.cpp
+++ b/examples/fabric-admin/device_manager/CommissionerControl.cpp
@@ -1,8 +1,10 @@
#include "CommissionerControl.h"
-#include <device_manager/DeviceManager.h>
+#include "DeviceManager.h"
using namespace ::chip;
+namespace admin {
+
void CommissionerControl::Init(Controller::DeviceCommissioner & commissioner, NodeId nodeId, EndpointId endpointId)
{
// Ensure that mCommissioner is not already initialized
@@ -102,6 +104,9 @@
CHIP_ERROR CommissionerControl::SendCommandForType(CommandType commandType, DeviceProxy * device)
{
+ ChipLogProgress(AppServer, "Sending command with Endpoint ID: %d, Command Type: %d", mEndpointId,
+ static_cast<int>(commandType));
+
switch (commandType)
{
case CommandType::kRequestCommissioningApproval:
@@ -139,3 +144,5 @@
VerifyOrReturn(self != nullptr, ChipLogError(NotSpecified, "OnDeviceConnectedFn: context is null"));
self->OnDone(nullptr);
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/CommissionerControl.h b/examples/fabric-admin/device_manager/CommissionerControl.h
index 1fad323..392367d 100644
--- a/examples/fabric-admin/device_manager/CommissionerControl.h
+++ b/examples/fabric-admin/device_manager/CommissionerControl.h
@@ -21,6 +21,8 @@
#include <app/CommandSender.h>
#include <controller/CHIPDeviceController.h>
+namespace admin {
+
/**
* @class CommissionerControl
* @brief This class handles sending CHIP commands related to commissioning, including sending
@@ -123,3 +125,5 @@
chip::app::Clusters::CommissionerControl::Commands::RequestCommissioningApproval::Type mRequestCommissioningApproval;
chip::app::Clusters::CommissionerControl::Commands::CommissionNode::Type mCommissionNode;
};
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/DeviceManager.cpp b/examples/fabric-admin/device_manager/DeviceManager.cpp
index e52027c..fafae0e 100644
--- a/examples/fabric-admin/device_manager/DeviceManager.cpp
+++ b/examples/fabric-admin/device_manager/DeviceManager.cpp
@@ -27,6 +27,8 @@
using namespace chip;
+namespace admin {
+
namespace {
constexpr EndpointId kAggregatorEndpointId = 1;
@@ -465,3 +467,5 @@
RemoveSyncedDevice(deviceId);
ChipLogProgress(NotSpecified, "Synced device with NodeId:" ChipLogFormatX64 " has been removed.", ChipLogValueX64(deviceId));
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/DeviceManager.h b/examples/fabric-admin/device_manager/DeviceManager.h
index 6adc8f2..9d2a37a 100644
--- a/examples/fabric-admin/device_manager/DeviceManager.h
+++ b/examples/fabric-admin/device_manager/DeviceManager.h
@@ -26,6 +26,8 @@
#include <platform/CHIPDeviceLayer.h>
#include <set>
+namespace admin {
+
constexpr uint32_t kDefaultSetupPinCode = 20202021;
constexpr uint16_t kDefaultLocalBridgePort = 5540;
constexpr uint16_t kResponseTimeoutSeconds = 30;
@@ -226,3 +228,5 @@
}
return DeviceManager::sInstance;
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/DeviceSubscription.cpp b/examples/fabric-admin/device_manager/DeviceSubscription.cpp
index 434d349..996656a 100644
--- a/examples/fabric-admin/device_manager/DeviceSubscription.cpp
+++ b/examples/fabric-admin/device_manager/DeviceSubscription.cpp
@@ -33,6 +33,8 @@
using namespace ::chip::app;
using chip::app::ReadClient;
+namespace admin {
+
namespace {
void OnDeviceConnectedWrapper(void * context, Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
@@ -281,3 +283,5 @@
MoveToState(State::AwaitingDestruction);
mOnDoneCallback(mScopedNodeId);
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/DeviceSubscription.h b/examples/fabric-admin/device_manager/DeviceSubscription.h
index 8db31d6..808da10 100644
--- a/examples/fabric-admin/device_manager/DeviceSubscription.h
+++ b/examples/fabric-admin/device_manager/DeviceSubscription.h
@@ -20,7 +20,6 @@
#include <app/ReadClient.h>
#include <controller/CHIPDeviceController.h>
#include <lib/core/DataModelTypes.h>
-
#include <memory>
#if defined(PW_RPC_ENABLED)
@@ -28,6 +27,8 @@
#include "fabric_bridge_service/fabric_bridge_service.rpc.pb.h"
#endif
+namespace admin {
+
class DeviceSubscriptionManager;
/// Attribute subscription to attributes that are important to keep track and send to fabric-bridge
@@ -95,3 +96,5 @@
bool mChangeDetected = false;
State mState = State::Idle;
};
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/DeviceSubscriptionManager.cpp b/examples/fabric-admin/device_manager/DeviceSubscriptionManager.cpp
index 0410c16..ca79cd0 100644
--- a/examples/fabric-admin/device_manager/DeviceSubscriptionManager.cpp
+++ b/examples/fabric-admin/device_manager/DeviceSubscriptionManager.cpp
@@ -32,6 +32,8 @@
using namespace ::chip;
using namespace ::chip::app;
+namespace admin {
+
DeviceSubscriptionManager & DeviceSubscriptionManager::Instance()
{
static DeviceSubscriptionManager instance;
@@ -78,3 +80,5 @@
VerifyOrDie(it != mDeviceSubscriptionMap.end());
mDeviceSubscriptionMap.erase(scopedNodeId);
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/DeviceSubscriptionManager.h b/examples/fabric-admin/device_manager/DeviceSubscriptionManager.h
index 1b5c45f..eb32d3f 100644
--- a/examples/fabric-admin/device_manager/DeviceSubscriptionManager.h
+++ b/examples/fabric-admin/device_manager/DeviceSubscriptionManager.h
@@ -25,6 +25,8 @@
#include <memory>
+namespace admin {
+
class DeviceSubscriptionManager
{
public:
@@ -52,3 +54,5 @@
std::unordered_map<chip::ScopedNodeId, std::unique_ptr<DeviceSubscription>, ScopedNodeIdHasher> mDeviceSubscriptionMap;
};
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/DeviceSynchronization.cpp b/examples/fabric-admin/device_manager/DeviceSynchronization.cpp
index 1e8728e..a88df40 100644
--- a/examples/fabric-admin/device_manager/DeviceSynchronization.cpp
+++ b/examples/fabric-admin/device_manager/DeviceSynchronization.cpp
@@ -35,6 +35,8 @@
using namespace ::chip::app;
using chip::app::ReadClient;
+namespace admin {
+
namespace {
void OnDeviceConnectedWrapper(void * context, Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
@@ -324,3 +326,5 @@
}
return "N/A";
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/DeviceSynchronization.h b/examples/fabric-admin/device_manager/DeviceSynchronization.h
index 28880c6..8f089ef 100644
--- a/examples/fabric-admin/device_manager/DeviceSynchronization.h
+++ b/examples/fabric-admin/device_manager/DeviceSynchronization.h
@@ -22,7 +22,6 @@
#include <app/ReadClient.h>
#include <controller/CHIPDeviceController.h>
#include <lib/core/DataModelTypes.h>
-
#include <memory>
#if defined(PW_RPC_ENABLED)
@@ -30,6 +29,8 @@
#include "fabric_bridge_service/fabric_bridge_service.rpc.pb.h"
#endif
+namespace admin {
+
/// Ensures that device data is synchronized to the remote fabric bridge.
///
/// Includes a state machine that:
@@ -100,3 +101,5 @@
#endif
UniqueIdGetter mUniqueIdGetter;
};
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/FabricSyncGetter.cpp b/examples/fabric-admin/device_manager/FabricSyncGetter.cpp
index 5201048..7e51180 100644
--- a/examples/fabric-admin/device_manager/FabricSyncGetter.cpp
+++ b/examples/fabric-admin/device_manager/FabricSyncGetter.cpp
@@ -22,6 +22,8 @@
using namespace ::chip::app;
using chip::app::ReadClient;
+namespace admin {
+
namespace {
void OnDeviceConnectedWrapper(void * context, Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
@@ -119,3 +121,5 @@
OnDone(nullptr);
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/FabricSyncGetter.h b/examples/fabric-admin/device_manager/FabricSyncGetter.h
index d6d3a5b..bed3c2f 100644
--- a/examples/fabric-admin/device_manager/FabricSyncGetter.h
+++ b/examples/fabric-admin/device_manager/FabricSyncGetter.h
@@ -24,6 +24,8 @@
#include <memory>
#include <optional>
+namespace admin {
+
/**
* @brief Class used to get FabricSynchronization from SupportedDeviceCategories attribute of Commissioner Control Cluster.
*
@@ -73,3 +75,5 @@
chip::Callback::Callback<chip::OnDeviceConnected> mOnDeviceConnectedCallback;
chip::Callback::Callback<chip::OnDeviceConnectionFailure> mOnDeviceConnectionFailureCallback;
};
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/PairingManager.cpp b/examples/fabric-admin/device_manager/PairingManager.cpp
index 41b4c87..64e4fb4 100644
--- a/examples/fabric-admin/device_manager/PairingManager.cpp
+++ b/examples/fabric-admin/device_manager/PairingManager.cpp
@@ -35,6 +35,8 @@
using namespace ::chip;
using namespace ::chip::Controller;
+namespace admin {
+
namespace {
CHIP_ERROR GetPayload(const char * setUpCode, SetupPayload & payload)
@@ -655,3 +657,5 @@
}
});
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/PairingManager.h b/examples/fabric-admin/device_manager/PairingManager.h
index 50e64f9..2318acd 100644
--- a/examples/fabric-admin/device_manager/PairingManager.h
+++ b/examples/fabric-admin/device_manager/PairingManager.h
@@ -25,6 +25,8 @@
#include <controller/CurrentFabricRemover.h>
#include <crypto/CHIPCryptoPAL.h>
+namespace admin {
+
// Constants
constexpr uint16_t kMaxManualCodeLength = 22;
@@ -214,3 +216,5 @@
chip::Platform::UniquePtr<chip::Controller::CurrentFabricRemover> mCurrentFabricRemover;
chip::Callback::Callback<chip::Controller::OnCurrentFabricRemove> mCurrentFabricRemoveCallback;
};
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/UniqueIdGetter.cpp b/examples/fabric-admin/device_manager/UniqueIdGetter.cpp
index 3a6d6af..cc3567d 100644
--- a/examples/fabric-admin/device_manager/UniqueIdGetter.cpp
+++ b/examples/fabric-admin/device_manager/UniqueIdGetter.cpp
@@ -22,6 +22,8 @@
using namespace ::chip::app;
using chip::app::ReadClient;
+namespace admin {
+
namespace {
void OnDeviceConnectedWrapper(void * context, Messaging::ExchangeManager & exchangeMgr, const SessionHandle & sessionHandle)
@@ -139,3 +141,5 @@
OnDone(nullptr);
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/device_manager/UniqueIdGetter.h b/examples/fabric-admin/device_manager/UniqueIdGetter.h
index 86d5d82..eba4451 100644
--- a/examples/fabric-admin/device_manager/UniqueIdGetter.h
+++ b/examples/fabric-admin/device_manager/UniqueIdGetter.h
@@ -24,6 +24,8 @@
#include <memory>
#include <optional>
+namespace admin {
+
/**
* @brief Class used to get UniqueID from Bridged Device Basic Information Cluster
*
@@ -73,3 +75,5 @@
char mUniqueId[33];
chip::EndpointId mEndpointId;
};
+
+} // namespace admin
diff --git a/examples/fabric-admin/main.cpp b/examples/fabric-admin/main.cpp
index 5768abf..15471ee 100644
--- a/examples/fabric-admin/main.cpp
+++ b/examples/fabric-admin/main.cpp
@@ -32,7 +32,7 @@
void ApplicationInit()
{
- DeviceMgr().Init();
+ admin::DeviceMgr().Init();
}
// ================================================================================
diff --git a/examples/fabric-admin/rpc/RpcClient.cpp b/examples/fabric-admin/rpc/RpcClient.cpp
index 9964dc6..a3bc459 100644
--- a/examples/fabric-admin/rpc/RpcClient.cpp
+++ b/examples/fabric-admin/rpc/RpcClient.cpp
@@ -28,6 +28,8 @@
using namespace chip;
+namespace admin {
+
namespace {
// Constants
@@ -227,3 +229,5 @@
return WaitForResponse(call);
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/rpc/RpcClient.h b/examples/fabric-admin/rpc/RpcClient.h
index a4cefe8..642e263 100644
--- a/examples/fabric-admin/rpc/RpcClient.h
+++ b/examples/fabric-admin/rpc/RpcClient.h
@@ -23,6 +23,8 @@
#include "fabric_bridge_service/fabric_bridge_service.rpc.pb.h"
+namespace admin {
+
/**
* @brief Sets the RPC server port to which the RPC client will connect.
*
@@ -99,3 +101,5 @@
* - CHIP_ERROR_INTERNAL: An internal error occurred while activating the RPC call.
*/
CHIP_ERROR DeviceReachableChanged(const chip_rpc_ReachabilityChanged & data);
+
+} // namespace admin
diff --git a/examples/fabric-admin/rpc/RpcServer.cpp b/examples/fabric-admin/rpc/RpcServer.cpp
index e10bb64..1b084ef 100644
--- a/examples/fabric-admin/rpc/RpcServer.cpp
+++ b/examples/fabric-admin/rpc/RpcServer.cpp
@@ -38,6 +38,8 @@
using namespace ::chip;
+namespace admin {
+
namespace {
#if defined(PW_RPC_FABRIC_ADMIN_SERVICE) && PW_RPC_FABRIC_ADMIN_SERVICE
@@ -254,3 +256,5 @@
std::thread rpc_service(RunRpcService);
rpc_service.detach();
}
+
+} // namespace admin
diff --git a/examples/fabric-admin/rpc/RpcServer.h b/examples/fabric-admin/rpc/RpcServer.h
index d283c0d..c8fcd33 100644
--- a/examples/fabric-admin/rpc/RpcServer.h
+++ b/examples/fabric-admin/rpc/RpcServer.h
@@ -18,4 +18,8 @@
#pragma once
+namespace admin {
+
void InitRpcServer(uint16_t rpcServerPort);
+
+} // namespace admin