[Fabric-Bridge] Put fabric sync logic into namespace 'bridge' (#36362)
diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedAdministratorCommissioning.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedAdministratorCommissioning.h
index 06fd902..7b5711d 100644
--- a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedAdministratorCommissioning.h
+++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedAdministratorCommissioning.h
@@ -20,6 +20,8 @@
#include <app-common/zap-generated/cluster-objects.h>
#include <app/AttributeAccessInterfaceRegistry.h>
+namespace bridge {
+
/**
* @brief CADMIN cluster implementation for handling attribute interactions of bridged device endpoints.
*
@@ -56,3 +58,5 @@
// to reflect this change.
chip::app::AttributeAccessInterface * mOriginalAttributeInterface = nullptr;
};
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h
index d2c5a64..ed5c971 100644
--- a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h
+++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h
@@ -23,6 +23,8 @@
#include <string>
+namespace bridge {
+
class BridgedDevice
{
public:
@@ -90,3 +92,5 @@
BridgedAttributes mAttributes;
AdminCommissioningAttributes mAdminCommissioningAttributes;
};
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceBasicInformationImpl.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceBasicInformationImpl.h
index 2340343..f57f7d0 100644
--- a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceBasicInformationImpl.h
+++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceBasicInformationImpl.h
@@ -18,6 +18,8 @@
#include <app-common/zap-generated/ids/Clusters.h>
#include <app/AttributeAccessInterface.h>
+namespace bridge {
+
class BridgedDeviceBasicInformationImpl : public chip::app::AttributeAccessInterface
{
public:
@@ -30,3 +32,5 @@
CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & path, chip::app::AttributeValueEncoder & encoder) override;
CHIP_ERROR Write(const chip::app::ConcreteDataAttributePath & path, chip::app::AttributeValueDecoder & decoder) override;
};
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceManager.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceManager.h
index 127898f..1a6a579 100644
--- a/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceManager.h
+++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceManager.h
@@ -24,6 +24,8 @@
#include <memory>
+namespace bridge {
+
class BridgedDeviceManager
{
public:
@@ -134,3 +136,5 @@
{
return BridgedDeviceManager::sInstance;
}
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedAdministratorCommissioning.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedAdministratorCommissioning.cpp
index a0d87cb..3299df7 100644
--- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedAdministratorCommissioning.cpp
+++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedAdministratorCommissioning.cpp
@@ -26,6 +26,8 @@
using namespace chip::app::Clusters;
using namespace chip::app::Clusters::AdministratorCommissioning;
+namespace bridge {
+
CHIP_ERROR BridgedAdministratorCommissioning::Init()
{
// We expect initialization after emberAfInit(). This allows us to unregister the existing
@@ -79,3 +81,5 @@
return CHIP_NO_ERROR;
}
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp
index f462d1c..bd88c89 100644
--- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp
+++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp
@@ -27,6 +27,8 @@
using namespace chip;
using namespace chip::app::Clusters::Actions;
+namespace bridge {
+
BridgedDevice::BridgedDevice(ScopedNodeId scopedNodeId)
{
mReachable = false;
@@ -116,3 +118,5 @@
}
});
}
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceBasicInformationImpl.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceBasicInformationImpl.cpp
index 7fa48a4..d021671 100644
--- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceBasicInformationImpl.cpp
+++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceBasicInformationImpl.cpp
@@ -29,6 +29,8 @@
using namespace ::chip::app;
using namespace ::chip::app::Clusters;
+namespace bridge {
+
CHIP_ERROR BridgedDeviceBasicInformationImpl::Read(const ConcreteReadAttributePath & path, AttributeValueEncoder & encoder)
{
// Registration is done for the bridged device basic information only
@@ -105,3 +107,5 @@
return CHIP_ERROR_INVALID_ARGUMENT;
}
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp
index 0265f91..babe2db 100644
--- a/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp
+++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp
@@ -45,6 +45,8 @@
using namespace chip::DeviceLayer;
using namespace chip::app::Clusters;
+namespace bridge {
+
namespace {
constexpr uint8_t kMaxRetries = 10;
@@ -343,3 +345,5 @@
}
return std::nullopt;
}
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/linux/CommissionerControlDelegate.cpp b/examples/fabric-bridge-app/linux/CommissionerControlDelegate.cpp
index 8a5c5af..aa12a42 100644
--- a/examples/fabric-bridge-app/linux/CommissionerControlDelegate.cpp
+++ b/examples/fabric-bridge-app/linux/CommissionerControlDelegate.cpp
@@ -186,13 +186,13 @@
VerifyOrReturnError(mNextStep == Step::kStartCommissionNode, CHIP_ERROR_INCORRECT_STATE);
#if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE
- err = CommissionNode(Controller::CommissioningWindowPasscodeParams()
- .SetSetupPIN(kSetupPinCode)
- .SetTimeout(params.commissioningTimeout)
- .SetDiscriminator(params.discriminator)
- .SetIteration(params.iterations)
- .SetSalt(params.salt),
- mVendorId, mProductId);
+ err = bridge::CommissionNode(Controller::CommissioningWindowPasscodeParams()
+ .SetSetupPIN(kSetupPinCode)
+ .SetTimeout(params.commissioningTimeout)
+ .SetDiscriminator(params.discriminator)
+ .SetIteration(params.iterations)
+ .SetSalt(params.salt),
+ mVendorId, mProductId);
#else
ChipLogProgress(NotSpecified, "Failed to reverse commission bridge: PW_RPC_FABRIC_BRIDGE_SERVICE not defined");
err = CHIP_ERROR_NOT_IMPLEMENTED;
@@ -209,6 +209,8 @@
} // namespace app
} // namespace chip
+namespace bridge {
+
CHIP_ERROR CommissionerControlInit()
{
CHIP_ERROR err;
@@ -262,3 +264,5 @@
return CHIP_NO_ERROR;
}
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/linux/RpcClient.cpp b/examples/fabric-bridge-app/linux/RpcClient.cpp
index 732fdf8..ef41ae2 100644
--- a/examples/fabric-bridge-app/linux/RpcClient.cpp
+++ b/examples/fabric-bridge-app/linux/RpcClient.cpp
@@ -35,6 +35,8 @@
using namespace chip;
+namespace bridge {
+
namespace {
// Constants
@@ -205,3 +207,5 @@
return WaitForResponse(call);
}
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/linux/RpcServer.cpp b/examples/fabric-bridge-app/linux/RpcServer.cpp
index 5fea43c..a34692b 100644
--- a/examples/fabric-bridge-app/linux/RpcServer.cpp
+++ b/examples/fabric-bridge-app/linux/RpcServer.cpp
@@ -37,6 +37,8 @@
using namespace chip::app;
using namespace chip::app::Clusters;
+namespace bridge {
+
namespace {
#if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE
@@ -256,3 +258,5 @@
std::thread rpc_service(RunRpcService);
rpc_service.detach();
}
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/linux/include/CommissionerControlDelegate.h b/examples/fabric-bridge-app/linux/include/CommissionerControlDelegate.h
index fceb80c..2f9e15f 100644
--- a/examples/fabric-bridge-app/linux/include/CommissionerControlDelegate.h
+++ b/examples/fabric-bridge-app/linux/include/CommissionerControlDelegate.h
@@ -89,5 +89,9 @@
} // namespace app
} // namespace chip
+namespace bridge {
+
CHIP_ERROR CommissionerControlInit();
CHIP_ERROR CommissionerControlShutdown();
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/linux/include/RpcClient.h b/examples/fabric-bridge-app/linux/include/RpcClient.h
index 1ede84f..9a06686 100644
--- a/examples/fabric-bridge-app/linux/include/RpcClient.h
+++ b/examples/fabric-bridge-app/linux/include/RpcClient.h
@@ -22,6 +22,8 @@
#include <lib/core/ScopedNodeId.h>
#include <platform/CHIPDeviceLayer.h>
+namespace bridge {
+
/**
* Sets the RPC server port to which the RPC client will connect.
*
@@ -70,3 +72,5 @@
CommissionNode(chip::Controller::CommissioningWindowPasscodeParams params, chip::VendorId vendorId, uint16_t productId);
CHIP_ERROR KeepActive(chip::ScopedNodeId scopedNodeId, uint32_t stayActiveDurationMs, uint32_t timeoutMs);
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/linux/include/RpcServer.h b/examples/fabric-bridge-app/linux/include/RpcServer.h
index d283c0d..ab0626c 100644
--- a/examples/fabric-bridge-app/linux/include/RpcServer.h
+++ b/examples/fabric-bridge-app/linux/include/RpcServer.h
@@ -18,4 +18,8 @@
#pragma once
+namespace bridge {
+
void InitRpcServer(uint16_t rpcServerPort);
+
+} // namespace bridge
diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp
index 5740534..cca3fbc 100644
--- a/examples/fabric-bridge-app/linux/main.cpp
+++ b/examples/fabric-bridge-app/linux/main.cpp
@@ -98,7 +98,7 @@
#if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE
void AttemptRpcClientConnect(System::Layer * systemLayer, void * appState)
{
- if (StartRpcClient() == CHIP_NO_ERROR)
+ if (bridge::StartRpcClient() == CHIP_NO_ERROR)
{
ChipLogProgress(NotSpecified, "Connected to Fabric-Admin");
}
@@ -110,6 +110,10 @@
}
#endif // defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE
+} // namespace
+
+namespace bridge {
+
class AdministratorCommissioningCommandHandler : public CommandHandlerInterface
{
public:
@@ -241,27 +245,27 @@
AdministratorCommissioningCommandHandler gAdministratorCommissioningCommandHandler;
BridgedDeviceInformationCommandHandler gBridgedDeviceInformationCommandHandler;
-} // namespace
+} // namespace bridge
void ApplicationInit()
{
ChipLogDetail(NotSpecified, "Fabric-Bridge: ApplicationInit()");
MatterEcosystemInformationPluginServerInitCallback();
- CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&gAdministratorCommissioningCommandHandler);
- CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&gBridgedDeviceInformationCommandHandler);
- AttributeAccessInterfaceRegistry::Instance().Register(&gBridgedDeviceBasicInformationAttributes);
+ CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&bridge::gAdministratorCommissioningCommandHandler);
+ CommandHandlerInterfaceRegistry::Instance().RegisterCommandHandler(&bridge::gBridgedDeviceInformationCommandHandler);
+ AttributeAccessInterfaceRegistry::Instance().Register(&bridge::gBridgedDeviceBasicInformationAttributes);
#if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE
- SetRpcRemoteServerPort(gFabricAdminServerPort);
- InitRpcServer(gLocalServerPort);
+ bridge::SetRpcRemoteServerPort(gFabricAdminServerPort);
+ bridge::InitRpcServer(gLocalServerPort);
AttemptRpcClientConnect(&DeviceLayer::SystemLayer(), nullptr);
#endif
- BridgeDeviceMgr().Init();
- VerifyOrDie(gBridgedAdministratorCommissioning.Init() == CHIP_NO_ERROR);
+ bridge::BridgeDeviceMgr().Init();
+ VerifyOrDie(bridge::gBridgedAdministratorCommissioning.Init() == CHIP_NO_ERROR);
- VerifyOrDieWithMsg(CommissionerControlInit() == CHIP_NO_ERROR, NotSpecified,
+ VerifyOrDieWithMsg(bridge::CommissionerControlInit() == CHIP_NO_ERROR, NotSpecified,
"Failed to initialize Commissioner Control Server");
}
@@ -269,7 +273,7 @@
{
ChipLogDetail(NotSpecified, "Fabric-Bridge: ApplicationShutdown()");
- if (CommissionerControlShutdown() != CHIP_NO_ERROR)
+ if (bridge::CommissionerControlShutdown() != CHIP_NO_ERROR)
{
ChipLogError(NotSpecified, "Failed to shutdown Commissioner Control Server");
}