diff --git a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn index 3bc4c23b9e0f92..10cb48c31c584e 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn +++ b/examples/fabric-bridge-app/fabric-bridge-common/BUILD.gn @@ -29,11 +29,11 @@ source_set("fabric-bridge-lib") { public_configs = [ ":config" ] sources = [ + "include/BridgedDevice.h", + "include/BridgedDeviceManager.h", "include/CHIPProjectAppConfig.h", - "include/Device.h", - "include/DeviceManager.h", - "src/Device.cpp", - "src/DeviceManager.cpp", + "src/BridgedDevice.cpp", + "src/BridgedDeviceManager.cpp", "src/ZCLCallbacks.cpp", ] diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/Device.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h similarity index 95% rename from examples/fabric-bridge-app/fabric-bridge-common/include/Device.h rename to examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h index c709af8cf0695b..a237d93d133eb7 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/include/Device.h +++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDevice.h @@ -27,13 +27,13 @@ #include #include -class Device +class BridgedDevice { public: static const int kDeviceNameSize = 32; - Device(chip::NodeId nodeId); - virtual ~Device() {} + BridgedDevice(chip::NodeId nodeId); + virtual ~BridgedDevice() {} bool IsReachable(); void SetReachable(bool reachable); diff --git a/examples/fabric-bridge-app/fabric-bridge-common/include/DeviceManager.h b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceManager.h similarity index 76% rename from examples/fabric-bridge-app/fabric-bridge-common/include/DeviceManager.h rename to examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceManager.h index b1dd791033511f..8411ec656f9803 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/include/DeviceManager.h +++ b/examples/fabric-bridge-app/fabric-bridge-common/include/BridgedDeviceManager.h @@ -20,17 +20,17 @@ #include -#include "Device.h" +#include "BridgedDevice.h" -class DeviceManager +class BridgedDeviceManager { public: - DeviceManager() = default; + BridgedDeviceManager() = default; /** - * @brief Initializes the DeviceManager. + * @brief Initializes the BridgedDeviceManager. * - * This function sets up the initial state of the DeviceManager, clearing + * This function sets up the initial state of the BridgedDeviceManager, clearing * any existing devices and setting the starting dynamic endpoint ID. */ void Init(); @@ -47,7 +47,7 @@ class DeviceManager * @param parentEndpointId The parent endpoint ID. Defaults to an invalid endpoint ID. * @return int The index of the dynamic endpoint if successful, -1 otherwise. */ - int AddDeviceEndpoint(Device * dev, chip::EndpointId parentEndpointId = chip::kInvalidEndpointId); + int AddDeviceEndpoint(BridgedDevice * dev, chip::EndpointId parentEndpointId = chip::kInvalidEndpointId); /** * @brief Removes a device from a dynamic endpoint. @@ -60,7 +60,7 @@ class DeviceManager * @param dev A pointer to the device to be removed. * @return int The index of the removed dynamic endpoint if successful, -1 otherwise. */ - int RemoveDeviceEndpoint(Device * dev); + int RemoveDeviceEndpoint(BridgedDevice * dev); /** * @brief Gets a device from its endpoint ID. @@ -69,9 +69,9 @@ class DeviceManager * specified endpoint ID. If no device matches the endpoint ID, it returns nullptr. * * @param endpointId The endpoint ID of the device to be retrieved. - * @return Device* A pointer to the device if found, nullptr otherwise. + * @return BridgedDevice* A pointer to the device if found, nullptr otherwise. */ - Device * GetDevice(chip::EndpointId endpointId) const; + BridgedDevice * GetDevice(chip::EndpointId endpointId) const; /** * @brief Gets a device from its NodeId. @@ -80,9 +80,9 @@ class DeviceManager * specified NodeId. If no device matches the NodeId, it returns nullptr. * * @param nodeId The NodeId of the device to be retrieved. - * @return Device* A pointer to the device if found, nullptr otherwise. + * @return BridgedDevice* A pointer to the device if found, nullptr otherwise. */ - Device * GetDeviceByNodeId(chip::NodeId nodeId) const; + BridgedDevice * GetDeviceByNodeId(chip::NodeId nodeId) const; /** * @brief Removes a device from a dynamic endpoint by its NodeId. @@ -98,22 +98,22 @@ class DeviceManager int RemoveDeviceByNodeId(chip::NodeId nodeId); private: - friend DeviceManager & DeviceMgr(); + friend BridgedDeviceManager & BridgeDeviceMgr(); - static DeviceManager sInstance; + static BridgedDeviceManager sInstance; chip::EndpointId mCurrentEndpointId; chip::EndpointId mFirstDynamicEndpointId; - Device * mDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT + 1]; + BridgedDevice * mDevices[CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT + 1]; }; /** - * Returns the public interface of the DeviceManager singleton object. + * Returns the public interface of the BridgedDeviceManager singleton object. * - * Applications should use this to access features of the DeviceManager + * Applications should use this to access features of the BridgedDeviceManager * object. */ -inline DeviceManager & DeviceMgr() +inline BridgedDeviceManager & BridgeDeviceMgr() { - return DeviceManager::sInstance; + return BridgedDeviceManager::sInstance; } diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/Device.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp similarity index 70% rename from examples/fabric-bridge-app/fabric-bridge-common/src/Device.cpp rename to examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp index e72fd856513b5a..d641f3743d43f0 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/Device.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDevice.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "Device.h" +#include "BridgedDevice.h" #include #include @@ -25,35 +25,35 @@ using namespace chip::app::Clusters::Actions; -Device::Device(chip::NodeId nodeId) +BridgedDevice::BridgedDevice(chip::NodeId nodeId) { mReachable = false; mNodeId = nodeId; mEndpointId = chip::kInvalidEndpointId; } -bool Device::IsReachable() +bool BridgedDevice::IsReachable() { return mReachable; } -void Device::SetReachable(bool reachable) +void BridgedDevice::SetReachable(bool reachable) { mReachable = reachable; if (reachable) { - ChipLogProgress(NotSpecified, "Device[%s]: ONLINE", mName); + ChipLogProgress(NotSpecified, "BridgedDevice[%s]: ONLINE", mName); } else { - ChipLogProgress(NotSpecified, "Device[%s]: OFFLINE", mName); + ChipLogProgress(NotSpecified, "BridgedDevice[%s]: OFFLINE", mName); } } -void Device::SetName(const char * name) +void BridgedDevice::SetName(const char * name) { - ChipLogProgress(NotSpecified, "Device[%s]: New Name=\"%s\"", mName, name); + ChipLogProgress(NotSpecified, "BridgedDevice[%s]: New Name=\"%s\"", mName, name); chip::Platform::CopyString(mName, name); } diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/DeviceManager.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp similarity index 95% rename from examples/fabric-bridge-app/fabric-bridge-common/src/DeviceManager.cpp rename to examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp index bc70c0cb0fe609..170b39cd2c94e2 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/DeviceManager.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/BridgedDeviceManager.cpp @@ -16,7 +16,7 @@ * limitations under the License. */ -#include "DeviceManager.h" +#include "BridgedDeviceManager.h" #include #include @@ -121,9 +121,9 @@ const EmberAfDeviceType sBridgedDeviceTypes[] = { { DEVICE_TYPE_BRIDGED_NODE, DE } // namespace // Define the static member -DeviceManager DeviceManager::sInstance; +BridgedDeviceManager BridgedDeviceManager::sInstance; -void DeviceManager::Init() +void BridgedDeviceManager::Init() { memset(mDevices, 0, sizeof(mDevices)); mFirstDynamicEndpointId = static_cast( @@ -131,7 +131,7 @@ void DeviceManager::Init() mCurrentEndpointId = mFirstDynamicEndpointId; } -int DeviceManager::AddDeviceEndpoint(Device * dev, chip::EndpointId parentEndpointId) +int BridgedDeviceManager::AddDeviceEndpoint(BridgedDevice * dev, chip::EndpointId parentEndpointId) { uint8_t index = 0; EmberAfEndpointType * ep = &sBridgedNodeEndpoint; @@ -181,7 +181,7 @@ int DeviceManager::AddDeviceEndpoint(Device * dev, chip::EndpointId parentEndpoi return -1; } -int DeviceManager::RemoveDeviceEndpoint(Device * dev) +int BridgedDeviceManager::RemoveDeviceEndpoint(BridgedDevice * dev) { uint8_t index = 0; while (index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT) @@ -201,7 +201,7 @@ int DeviceManager::RemoveDeviceEndpoint(Device * dev) return -1; } -Device * DeviceManager::GetDevice(chip::EndpointId endpointId) const +BridgedDevice * BridgedDeviceManager::GetDevice(chip::EndpointId endpointId) const { for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index) { @@ -213,7 +213,7 @@ Device * DeviceManager::GetDevice(chip::EndpointId endpointId) const return nullptr; } -Device * DeviceManager::GetDeviceByNodeId(chip::NodeId nodeId) const +BridgedDevice * BridgedDeviceManager::GetDeviceByNodeId(chip::NodeId nodeId) const { for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index) { @@ -225,7 +225,7 @@ Device * DeviceManager::GetDeviceByNodeId(chip::NodeId nodeId) const return nullptr; } -int DeviceManager::RemoveDeviceByNodeId(chip::NodeId nodeId) +int BridgedDeviceManager::RemoveDeviceByNodeId(chip::NodeId nodeId) { for (uint8_t index = 0; index < CHIP_DEVICE_CONFIG_DYNAMIC_ENDPOINT_COUNT; ++index) { diff --git a/examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp b/examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp index 1655df4c2f1399..9a0467be4e27e8 100644 --- a/examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp +++ b/examples/fabric-bridge-app/fabric-bridge-common/src/ZCLCallbacks.cpp @@ -15,7 +15,7 @@ * limitations under the License. */ -#include "DeviceManager.h" +#include "BridgedDeviceManager.h" #include #include @@ -36,7 +36,7 @@ Protocols::InteractionModel::Status emberAfExternalAttributeReadCallback(Endpoin { AttributeId attributeId = attributeMetadata->attributeId; - Device * dev = DeviceMgr().GetDevice(endpoint); + BridgedDevice * dev = BridgeDeviceMgr().GetDevice(endpoint); if (dev != nullptr && clusterId == app::Clusters::BridgedDeviceBasicInformation::Id) { using namespace app::Clusters::BridgedDeviceBasicInformation::Attributes; @@ -80,7 +80,7 @@ Protocols::InteractionModel::Status emberAfExternalAttributeWriteCallback(Endpoi uint16_t endpointIndex = emberAfGetDynamicIndexFromEndpoint(endpoint); Protocols::InteractionModel::Status ret = Protocols::InteractionModel::Status::Failure; - Device * dev = DeviceMgr().GetDevice(endpointIndex); + BridgedDevice * dev = BridgeDeviceMgr().GetDevice(endpointIndex); if (dev != nullptr && dev->IsReachable()) { ChipLogProgress(NotSpecified, "emberAfExternalAttributeWriteCallback: ep=%d, clusterId=%d", endpoint, clusterId); diff --git a/examples/fabric-bridge-app/linux/RpcServer.cpp b/examples/fabric-bridge-app/linux/RpcServer.cpp index d4044f043468d3..76fe8f84653d39 100644 --- a/examples/fabric-bridge-app/linux/RpcServer.cpp +++ b/examples/fabric-bridge-app/linux/RpcServer.cpp @@ -29,8 +29,8 @@ #include "pigweed/rpc_services/FabricBridge.h" #endif -#include "Device.h" -#include "DeviceManager.h" +#include "BridgedDevice.h" +#include "BridgedDeviceManager.h" using namespace chip; using namespace chip::app; @@ -51,10 +51,10 @@ pw::Status FabricBridge::AddSynchronizedDevice(const chip_rpc_SynchronizedDevice NodeId nodeId = request.node_id; ChipLogProgress(NotSpecified, "Received AddSynchronizedDevice: " ChipLogFormatX64, ChipLogValueX64(nodeId)); - Device * device = new Device(nodeId); + BridgedDevice * device = new BridgedDevice(nodeId); device->SetReachable(true); - int result = DeviceMgr().AddDeviceEndpoint(device, 1); + int result = BridgeDeviceMgr().AddDeviceEndpoint(device, 1); if (result == -1) { delete device; @@ -70,7 +70,7 @@ pw::Status FabricBridge::RemoveSynchronizedDevice(const chip_rpc_SynchronizedDev NodeId nodeId = request.node_id; ChipLogProgress(NotSpecified, "Received RemoveSynchronizedDevice: " ChipLogFormatX64, ChipLogValueX64(nodeId)); - int removed_idx = DeviceMgr().RemoveDeviceByNodeId(nodeId); + int removed_idx = BridgeDeviceMgr().RemoveDeviceByNodeId(nodeId); if (removed_idx < 0) { ChipLogError(NotSpecified, "Failed to remove device with nodeId=0x" ChipLogFormatX64, ChipLogValueX64(nodeId)); diff --git a/examples/fabric-bridge-app/linux/main.cpp b/examples/fabric-bridge-app/linux/main.cpp index d8fb45dea08a02..c708b256727520 100644 --- a/examples/fabric-bridge-app/linux/main.cpp +++ b/examples/fabric-bridge-app/linux/main.cpp @@ -18,9 +18,9 @@ #include +#include "BridgedDevice.h" +#include "BridgedDeviceManager.h" #include "CommissionableInit.h" -#include "Device.h" -#include "DeviceManager.h" #include #include @@ -140,7 +140,7 @@ void AdministratorCommissioningCommandHandler::InvokeCommand(HandlerContext & ha Status status = Status::Failure; #if defined(PW_RPC_FABRIC_BRIDGE_SERVICE) && PW_RPC_FABRIC_BRIDGE_SERVICE - Device * device = DeviceMgr().GetDevice(endpointId); + BridgedDevice * device = BridgeDeviceMgr().GetDevice(endpointId); // TODO: issues:#33784, need to make OpenCommissioningWindow synchronous if (device != nullptr && @@ -185,7 +185,7 @@ void ApplicationInit() std::thread pollingThread(BridgePollingThread); pollingThread.detach(); - DeviceMgr().Init(); + BridgeDeviceMgr().Init(); } void ApplicationShutdown()