Skip to content

Commit 7d9a332

Browse files
Rename to BridgedDevice and BridgedDeviceManager (#34776)
* Rename to BridgedDevice and BridgedDeviceManager * Restyled by clang-format * Restyled by gn --------- Co-authored-by: Restyled.io <commits@restyled.io>
1 parent 545b034 commit 7d9a332

File tree

8 files changed

+53
-53
lines changed

8 files changed

+53
-53
lines changed

examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn

+4-4
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,11 @@ source_set("fabric-bridge-lib") {
2929
public_configs = [ ":config" ]
3030

3131
sources = [
32+
"include/BridgedDevice.h",
33+
"include/BridgedDeviceManager.h",
3234
"include/CHIPProjectAppConfig.h",
33-
"include/Device.h",
34-
"include/DeviceManager.h",
35-
"src/Device.cpp",
36-
"src/DeviceManager.cpp",
35+
"src/BridgedDevice.cpp",
36+
"src/BridgedDeviceManager.cpp",
3737
"src/ZCLCallbacks.cpp",
3838
]
3939

examples/fabric-bridge-app/fabric-bridge-common/include/Device.h examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h

+3-3
Original file line numberDiff line numberDiff line change
@@ -27,13 +27,13 @@
2727
#include <string>
2828
#include <vector>
2929

30-
class Device
30+
class BridgedDevice
3131
{
3232
public:
3333
static const int kDeviceNameSize = 32;
3434

35-
Device(chip::NodeId nodeId);
36-
virtual ~Device() {}
35+
BridgedDevice(chip::NodeId nodeId);
36+
virtual ~BridgedDevice() {}
3737

3838
bool IsReachable();
3939
void SetReachable(bool reachable);

examples/fabric-bridge-app/fabric-bridge-common/include/DeviceManager.h examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceManager.h

+18-18
Original file line numberDiff line numberDiff line change
@@ -20,17 +20,17 @@
2020

2121
#include <platform/CHIPDeviceLayer.h>
2222

23-
#include "Device.h"
23+
#include "BridgedDevice.h"
2424

25-
class DeviceManager
25+
class BridgedDeviceManager
2626
{
2727
public:
28-
DeviceManager() = default;
28+
BridgedDeviceManager() = default;
2929

3030
/**
31-
* @brief Initializes the DeviceManager.
31+
* @brief Initializes the BridgedDeviceManager.
3232
*
33-
* This function sets up the initial state of the DeviceManager, clearing
33+
* This function sets up the initial state of the BridgedDeviceManager, clearing
3434
* any existing devices and setting the starting dynamic endpoint ID.
3535
*/
3636
void Init();
@@ -47,7 +47,7 @@ class DeviceManager
4747
* @param parentEndpointId The parent endpoint ID. Defaults to an invalid endpoint ID.
4848
* @return int The index of the dynamic endpoint if successful, -1 otherwise.
4949
*/
50-
int AddDeviceEndpoint(Device * dev, chip::EndpointId parentEndpointId = chip::kInvalidEndpointId);
50+
int AddDeviceEndpoint(BridgedDevice * dev, chip::EndpointId parentEndpointId = chip::kInvalidEndpointId);
5151

5252
/**
5353
* @brief Removes a device from a dynamic endpoint.
@@ -60,7 +60,7 @@ class DeviceManager
6060
* @param dev A pointer to the device to be removed.
6161
* @return int The index of the removed dynamic endpoint if successful, -1 otherwise.
6262
*/
63-
int RemoveDeviceEndpoint(Device * dev);
63+
int RemoveDeviceEndpoint(BridgedDevice * dev);
6464

6565
/**
6666
* @brief Gets a device from its endpoint ID.
@@ -69,9 +69,9 @@ class DeviceManager
6969
* specified endpoint ID. If no device matches the endpoint ID, it returns nullptr.
7070
*
7171
* @param endpointId The endpoint ID of the device to be retrieved.
72-
* @return Device* A pointer to the device if found, nullptr otherwise.
72+
* @return BridgedDevice* A pointer to the device if found, nullptr otherwise.
7373
*/
74-
Device * GetDevice(chip::EndpointId endpointId) const;
74+
BridgedDevice * GetDevice(chip::EndpointId endpointId) const;
7575

7676
/**
7777
* @brief Gets a device from its NodeId.
@@ -80,9 +80,9 @@ class DeviceManager
8080
* specified NodeId. If no device matches the NodeId, it returns nullptr.
8181
*
8282
* @param nodeId The NodeId of the device to be retrieved.
83-
* @return Device* A pointer to the device if found, nullptr otherwise.
83+
* @return BridgedDevice* A pointer to the device if found, nullptr otherwise.
8484
*/
85-
Device * GetDeviceByNodeId(chip::NodeId nodeId) const;
85+
BridgedDevice * GetDeviceByNodeId(chip::NodeId nodeId) const;
8686

8787
/**
8888
* @brief Removes a device from a dynamic endpoint by its NodeId.
@@ -98,22 +98,22 @@ class DeviceManager
9898
int RemoveDeviceByNodeId(chip::NodeId nodeId);
9999

100100
private:
101-
friend DeviceManager & DeviceMgr();
101+
friend BridgedDeviceManager & BridgeDeviceMgr();
102102

103-
static DeviceManager sInstance;
103+
static BridgedDeviceManager sInstance;
104104

105105
chip::EndpointId mCurrentEndpointId;
106106
chip::EndpointId mFirstDynamicEndpointId;
107-
Device * mDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT + 1];
107+
BridgedDevice * mDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT + 1];
108108
};
109109

110110
/**
111-
* Returns the public interface of the DeviceManager singleton object.
111+
* Returns the public interface of the BridgedDeviceManager singleton object.
112112
*
113-
* Applications should use this to access features of the DeviceManager
113+
* Applications should use this to access features of the BridgedDeviceManager
114114
* object.
115115
*/
116-
inline DeviceManager & DeviceMgr()
116+
inline BridgedDeviceManager & BridgeDeviceMgr()
117117
{
118-
return DeviceManager::sInstance;
118+
return BridgedDeviceManager::sInstance;
119119
}

examples/fabric-bridge-app/fabric-bridge-common/src/Device.cpp examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "Device.h"
19+
#include "BridgedDevice.h"
2020

2121
#include <cstdio>
2222
#include <platform/CHIPDeviceLayer.h>
@@ -25,35 +25,35 @@
2525

2626
using namespace chip::app::Clusters::Actions;
2727

28-
Device::Device(chip::NodeId nodeId)
28+
BridgedDevice::BridgedDevice(chip::NodeId nodeId)
2929
{
3030
mReachable = false;
3131
mNodeId = nodeId;
3232
mEndpointId = chip::kInvalidEndpointId;
3333
}
3434

35-
bool Device::IsReachable()
35+
bool BridgedDevice::IsReachable()
3636
{
3737
return mReachable;
3838
}
3939

40-
void Device::SetReachable(bool reachable)
40+
void BridgedDevice::SetReachable(bool reachable)
4141
{
4242
mReachable = reachable;
4343

4444
if (reachable)
4545
{
46-
ChipLogProgress(NotSpecified, "Device[%s]: ONLINE", mName);
46+
ChipLogProgress(NotSpecified, "BridgedDevice[%s]: ONLINE", mName);
4747
}
4848
else
4949
{
50-
ChipLogProgress(NotSpecified, "Device[%s]: OFFLINE", mName);
50+
ChipLogProgress(NotSpecified, "BridgedDevice[%s]: OFFLINE", mName);
5151
}
5252
}
5353

54-
void Device::SetName(const char * name)
54+
void BridgedDevice::SetName(const char * name)
5555
{
56-
ChipLogProgress(NotSpecified, "Device[%s]: New Name=\"%s\"", mName, name);
56+
ChipLogProgress(NotSpecified, "BridgedDevice[%s]: New Name=\"%s\"", mName, name);
5757

5858
chip::Platform::CopyString(mName, name);
5959
}

examples/fabric-bridge-app/fabric-bridge-common/src/DeviceManager.cpp examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp

+8-8
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@
1616
* limitations under the License.
1717
*/
1818

19-
#include "DeviceManager.h"
19+
#include "BridgedDeviceManager.h"
2020

2121
#include <app-common/zap-generated/ids/Attributes.h>
2222
#include <app-common/zap-generated/ids/Clusters.h>
@@ -121,17 +121,17 @@ const EmberAfDeviceType sBridgedDeviceTypes[] = { { DEVICE_TYPE_BRIDGED_NODE, DE
121121
} // namespace
122122

123123
// Define the static member
124-
DeviceManager DeviceManager::sInstance;
124+
BridgedDeviceManager BridgedDeviceManager::sInstance;
125125

126-
void DeviceManager::Init()
126+
void BridgedDeviceManager::Init()
127127
{
128128
memset(mDevices, 0, sizeof(mDevices));
129129
mFirstDynamicEndpointId = static_cast<chip::EndpointId>(
130130
static_cast<int>(emberAfEndpointFromIndex(static_cast<uint16_t>(emberAfFixedEndpointCount() - 1))) + 1);
131131
mCurrentEndpointId = mFirstDynamicEndpointId;
132132
}
133133

134-
int DeviceManager::AddDeviceEndpoint(Device * dev, chip::EndpointId parentEndpointId)
134+
int BridgedDeviceManager::AddDeviceEndpoint(BridgedDevice * dev, chip::EndpointId parentEndpointId)
135135
{
136136
uint8_t index = 0;
137137
EmberAfEndpointType * ep = &sBridgedNodeEndpoint;
@@ -181,7 +181,7 @@ int DeviceManager::AddDeviceEndpoint(Device * dev, chip::EndpointId parentEndpoi
181181
return -1;
182182
}
183183

184-
int DeviceManager::RemoveDeviceEndpoint(Device * dev)
184+
int BridgedDeviceManager::RemoveDeviceEndpoint(BridgedDevice * dev)
185185
{
186186
uint8_t index = 0;
187187
while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT)
@@ -201,7 +201,7 @@ int DeviceManager::RemoveDeviceEndpoint(Device * dev)
201201
return -1;
202202
}
203203

204-
Device * DeviceManager::GetDevice(chip::EndpointId endpointId) const
204+
BridgedDevice * BridgedDeviceManager::GetDevice(chip::EndpointId endpointId) const
205205
{
206206
for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
207207
{
@@ -213,7 +213,7 @@ Device * DeviceManager::GetDevice(chip::EndpointId endpointId) const
213213
return nullptr;
214214
}
215215

216-
Device * DeviceManager::GetDeviceByNodeId(chip::NodeId nodeId) const
216+
BridgedDevice * BridgedDeviceManager::GetDeviceByNodeId(chip::NodeId nodeId) const
217217
{
218218
for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
219219
{
@@ -225,7 +225,7 @@ Device * DeviceManager::GetDeviceByNodeId(chip::NodeId nodeId) const
225225
return nullptr;
226226
}
227227

228-
int DeviceManager::RemoveDeviceByNodeId(chip::NodeId nodeId)
228+
int BridgedDeviceManager::RemoveDeviceByNodeId(chip::NodeId nodeId)
229229
{
230230
for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index)
231231
{

examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp

+3-3
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
* limitations under the License.
1616
*/
1717

18-
#include "DeviceManager.h"
18+
#include "BridgedDeviceManager.h"
1919

2020
#include <app-common/zap-generated/cluster-objects.h>
2121
#include <app-common/zap-generated/ids/Attributes.h>
@@ -36,7 +36,7 @@ Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(Endpoin
3636
{
3737
AttributeId attributeId = attributeMetadata->attributeId;
3838

39-
Device * dev = DeviceMgr().GetDevice(endpoint);
39+
BridgedDevice * dev = BridgeDeviceMgr().GetDevice(endpoint);
4040
if (dev != nullptr && clusterId == app::Clusters::BridgedDeviceBasicInformation::Id)
4141
{
4242
using namespace app::Clusters::BridgedDeviceBasicInformation::Attributes;
@@ -80,7 +80,7 @@ Protocols::InteractionModel::Status emberAfExternalAttributeWriteCallback(Endpoi
8080
uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint);
8181
Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Failure;
8282

83-
Device * dev = DeviceMgr().GetDevice(endpointIndex);
83+
BridgedDevice * dev = BridgeDeviceMgr().GetDevice(endpointIndex);
8484
if (dev != nullptr && dev->IsReachable())
8585
{
8686
ChipLogProgress(NotSpecified, "emberAfExternalAttributeWriteCallback: ep=%d, clusterId=%d", endpoint, clusterId);

examples/fabric-bridge-app/linux/RpcServer.cpp

+5-5
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,8 @@
2929
#include "pigweed/rpc_services/FabricBridge.h"
3030
#endif
3131

32-
#include "Device.h"
33-
#include "DeviceManager.h"
32+
#include "BridgedDevice.h"
33+
#include "BridgedDeviceManager.h"
3434

3535
using namespace chip;
3636
using namespace chip::app;
@@ -51,10 +51,10 @@ pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice
5151
NodeId nodeId = request.node_id;
5252
ChipLogProgress(NotSpecified, "Received AddSynchronizedDevice: " ChipLogFormatX64, ChipLogValueX64(nodeId));
5353

54-
Device * device = new Device(nodeId);
54+
BridgedDevice * device = new BridgedDevice(nodeId);
5555
device->SetReachable(true);
5656

57-
int result = DeviceMgr().AddDeviceEndpoint(device, 1);
57+
int result = BridgeDeviceMgr().AddDeviceEndpoint(device, 1);
5858
if (result == -1)
5959
{
6060
delete device;
@@ -70,7 +70,7 @@ pw::Status FabricBridge::RemoveSynchronizedDevice(const chip_rpc_SynchronizedDev
7070
NodeId nodeId = request.node_id;
7171
ChipLogProgress(NotSpecified, "Received RemoveSynchronizedDevice: " ChipLogFormatX64, ChipLogValueX64(nodeId));
7272

73-
int removed_idx = DeviceMgr().RemoveDeviceByNodeId(nodeId);
73+
int removed_idx = BridgeDeviceMgr().RemoveDeviceByNodeId(nodeId);
7474
if (removed_idx < 0)
7575
{
7676
ChipLogError(NotSpecified, "Failed to remove device with nodeId=0x" ChipLogFormatX64, ChipLogValueX64(nodeId));

examples/fabric-bridge-app/linux/main.cpp

+4-4
Original file line numberDiff line numberDiff line change
@@ -18,9 +18,9 @@
1818

1919
#include <AppMain.h>
2020

21+
#include "BridgedDevice.h"
22+
#include "BridgedDeviceManager.h"
2123
#include "CommissionableInit.h"
22-
#include "Device.h"
23-
#include "DeviceManager.h"
2424

2525
#include <app/AttributeAccessInterfaceRegistry.h>
2626
#include <app/CommandHandlerInterfaceRegistry.h>
@@ -140,7 +140,7 @@ void AdministratorCommissioningCommandHandler::InvokeCommand(HandlerContext & ha
140140
Status status = Status::Failure;
141141

142142
#if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE
143-
Device * device = DeviceMgr().GetDevice(endpointId);
143+
BridgedDevice * device = BridgeDeviceMgr().GetDevice(endpointId);
144144

145145
// TODO: issues:#33784, need to make OpenCommissioningWindow synchronous
146146
if (device != nullptr &&
@@ -185,7 +185,7 @@ void ApplicationInit()
185185
std::thread pollingThread(BridgePollingThread);
186186
pollingThread.detach();
187187

188-
DeviceMgr().Init();
188+
BridgeDeviceMgr().Init();
189189
}
190190

191191
void ApplicationShutdown()

0 commit comments

Comments
 (0)