Skip to content

Commit 4fce9b9

Browse files
authored
[Fabric-Sync] use namespace to isolate admin and bridge (project-chip#36374)
1 parent 1c655f9 commit 4fce9b9

17 files changed

+76
-27
lines changed

examples/fabric-sync/admin/DeviceManager.cpp

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@
2626

2727
using namespace chip;
2828

29+
namespace admin {
2930
// Define the static member
3031
DeviceManager DeviceManager::sInstance;
3132

@@ -109,3 +110,5 @@ void DeviceManager::OnDeviceRemoved(NodeId deviceId, CHIP_ERROR err)
109110

110111
ChipLogProgress(NotSpecified, "Synced device with NodeId:" ChipLogFormatX64 " has been removed.", ChipLogValueX64(deviceId));
111112
}
113+
114+
} // namespace admin

examples/fabric-sync/admin/DeviceManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323
#include <app-common/zap-generated/cluster-objects.h>
2424
#include <platform/CHIPDeviceLayer.h>
2525

26+
namespace admin {
27+
2628
class DeviceManager : public PairingDelegate
2729
{
2830
public:
@@ -97,3 +99,5 @@ inline DeviceManager & DeviceMgr()
9799
}
98100
return DeviceManager::sInstance;
99101
}
102+
103+
} // namespace admin

examples/fabric-sync/admin/PairingManager.cpp

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
using namespace ::chip;
3030
using namespace ::chip::Controller;
3131

32+
namespace admin {
33+
3234
namespace {
3335

3436
CHIP_ERROR GetPayload(const char * setUpCode, SetupPayload & payload)
@@ -451,7 +453,7 @@ void PairingManager::OnCurrentFabricRemove(void * context, NodeId nodeId, CHIP_E
451453
if (err == CHIP_NO_ERROR)
452454
{
453455
// print to console
454-
fprintf(stderr, "Device with Node ID: " ChipLogFormatX64 "has been successfully removed.\n", ChipLogValueX64(nodeId));
456+
fprintf(stderr, "Device with Node ID: " ChipLogFormatX64 " has been successfully removed.\n", ChipLogValueX64(nodeId));
455457
}
456458
else
457459
{
@@ -548,3 +550,5 @@ CHIP_ERROR PairingManager::UnpairDevice(NodeId nodeId)
548550
}
549551
});
550552
}
553+
554+
} // namespace admin

examples/fabric-sync/admin/PairingManager.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424
#include <controller/CurrentFabricRemover.h>
2525
#include <crypto/CHIPCryptoPAL.h>
2626

27+
namespace admin {
28+
2729
// Constants
2830
constexpr uint16_t kMaxManualCodeLength = 22;
2931

@@ -201,3 +203,5 @@ class PairingManager : public chip::Controller::DevicePairingDelegate,
201203
chip::Platform::UniquePtr<chip::Controller::CurrentFabricRemover> mCurrentFabricRemover;
202204
chip::Callback::Callback<chip::Controller::OnCurrentFabricRemove> mCurrentFabricRemoveCallback;
203205
};
206+
207+
} // namespace admin

examples/fabric-sync/bridge/include/BridgedAdministratorCommissioning.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,6 +20,8 @@
2020
#include <app-common/zap-generated/cluster-objects.h>
2121
#include <app/AttributeAccessInterfaceRegistry.h>
2222

23+
namespace bridge {
24+
2325
/**
2426
* @brief CADMIN cluster implementation for handling attribute interactions of bridged device endpoints.
2527
*
@@ -56,3 +58,5 @@ class BridgedAdministratorCommissioning : public chip::app::AttributeAccessInter
5658
// to reflect this change.
5759
chip::app::AttributeAccessInterface * mOriginalAttributeInterface = nullptr;
5860
};
61+
62+
} // namespace bridge

examples/fabric-sync/bridge/include/BridgedDevice.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,8 @@
2323

2424
#include <string>
2525

26+
namespace bridge {
27+
2628
class BridgedDevice
2729
{
2830
public:
@@ -90,3 +92,5 @@ class BridgedDevice
9092
BridgedAttributes mAttributes;
9193
AdminCommissioningAttributes mAdminCommissioningAttributes;
9294
};
95+
96+
} // namespace bridge

examples/fabric-sync/bridge/include/BridgedDeviceBasicInformationImpl.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,8 @@
1818
#include <app-common/zap-generated/ids/Clusters.h>
1919
#include <app/AttributeAccessInterface.h>
2020

21+
namespace bridge {
22+
2123
class BridgedDeviceBasicInformationImpl : public chip::app::AttributeAccessInterface
2224
{
2325
public:
@@ -30,3 +32,5 @@ class BridgedDeviceBasicInformationImpl : public chip::app::AttributeAccessInter
3032
CHIP_ERROR Read(const chip::app::ConcreteReadAttributePath & path, chip::app::AttributeValueEncoder & encoder) override;
3133
CHIP_ERROR Write(const chip::app::ConcreteDataAttributePath & path, chip::app::AttributeValueDecoder & decoder) override;
3234
};
35+
36+
} // namespace bridge

examples/fabric-sync/bridge/include/BridgedDeviceManager.h

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,8 @@
2424

2525
#include <memory>
2626

27+
namespace bridge {
28+
2729
class BridgedDeviceManager
2830
{
2931
public:
@@ -52,9 +54,9 @@ class BridgedDeviceManager
5254
*
5355
* @param dev A pointer to the device to be added.
5456
* @param parentEndpointId The parent endpoint ID. Defaults to an invalid endpoint ID.
55-
* @return int The index of the dynamic endpoint if successful, nullopt otherwise
57+
* @return uint16_t The index of the dynamic endpoint if successful, nullopt otherwise
5658
*/
57-
std::optional<unsigned> AddDeviceEndpoint(std::unique_ptr<BridgedDevice> dev,
59+
std::optional<uint16_t> AddDeviceEndpoint(std::unique_ptr<BridgedDevice> dev,
5860
chip::EndpointId parentEndpointId = chip::kInvalidEndpointId);
5961

6062
/**
@@ -100,9 +102,9 @@ class BridgedDeviceManager
100102
* found, it removes the dynamic endpoint.
101103
*
102104
* @param scopedNodeId The ScopedNodeId of the device to be removed.
103-
* @return unsigned of the index of the removed dynamic endpoint if successful, nullopt otherwise.
105+
* @return uint16_t of the index of the removed dynamic endpoint if successful, nullopt otherwise.
104106
*/
105-
std::optional<unsigned> RemoveDeviceByScopedNodeId(chip::ScopedNodeId scopedNodeId);
107+
std::optional<uint16_t> RemoveDeviceByScopedNodeId(chip::ScopedNodeId scopedNodeId);
106108

107109
/**
108110
* Finds the device with the given unique id (if any)
@@ -134,3 +136,5 @@ inline BridgedDeviceManager & BridgeDeviceMgr()
134136
{
135137
return BridgedDeviceManager::sInstance;
136138
}
139+
140+
} // namespace bridge

examples/fabric-sync/bridge/src/BridgedAdministratorCommissioning.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,8 @@ using namespace chip::app;
2626
using namespace chip::app::Clusters;
2727
using namespace chip::app::Clusters::AdministratorCommissioning;
2828

29+
namespace bridge {
30+
2931
CHIP_ERROR BridgedAdministratorCommissioning::Init()
3032
{
3133
// We expect initialization after emberAfInit(). This allows us to unregister the existing
@@ -79,3 +81,5 @@ CHIP_ERROR BridgedAdministratorCommissioning::Read(const ConcreteReadAttributePa
7981

8082
return CHIP_NO_ERROR;
8183
}
84+
85+
} // namespace bridge

examples/fabric-sync/bridge/src/BridgedDevice.cpp

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,8 @@
2727
using namespace chip;
2828
using namespace chip::app::Clusters::Actions;
2929

30+
namespace bridge {
31+
3032
BridgedDevice::BridgedDevice(ScopedNodeId scopedNodeId)
3133
{
3234
mReachable = false;
@@ -116,3 +118,5 @@ void BridgedDevice::SetAdminCommissioningAttributes(const AdminCommissioningAttr
116118
}
117119
});
118120
}
121+
122+
} // namespace bridge

0 commit comments

Comments
 (0)