From 1158afe3c7b15c8a31aa547d9e50a08caf314dd5 Mon Sep 17 00:00:00 2001 From: Yufeng Wang Date: Mon, 22 Nov 2021 08:50:05 -0800 Subject: [PATCH] Address review comments --- examples/common/pigweed/rpc_services/Device.h | 2 +- src/platform/Tizen/PlatformManagerImpl.cpp | 2 +- .../Zephyr/DiagnosticDataProviderImpl.cpp | 7 +--- .../Zephyr/DiagnosticDataProviderImpl.h | 11 ----- src/platform/Zephyr/PlatformManagerImpl.cpp | 2 + src/platform/nrfconnect/BUILD.gn | 4 +- .../nrfconnect/DiagnosticDataProviderImpl.cpp | 40 ------------------- .../nrfconnect/DiagnosticDataProviderImpl.h | 40 ------------------- src/platform/telink/BUILD.gn | 4 +- .../telink/DiagnosticDataProviderImpl.cpp | 40 ------------------- .../telink/DiagnosticDataProviderImpl.h | 40 ------------------- 11 files changed, 9 insertions(+), 183 deletions(-) delete mode 100644 src/platform/nrfconnect/DiagnosticDataProviderImpl.cpp delete mode 100644 src/platform/nrfconnect/DiagnosticDataProviderImpl.h delete mode 100644 src/platform/telink/DiagnosticDataProviderImpl.cpp delete mode 100644 src/platform/telink/DiagnosticDataProviderImpl.h diff --git a/examples/common/pigweed/rpc_services/Device.h b/examples/common/pigweed/rpc_services/Device.h index e185aaf07a403d..289fe7438fc55f 100644 --- a/examples/common/pigweed/rpc_services/Device.h +++ b/examples/common/pigweed/rpc_services/Device.h @@ -55,7 +55,7 @@ class Device : public generated::Device virtual pw::Status GetDeviceState(ServerContext &, const pw_protobuf_Empty & request, chip_rpc_DeviceState & response) { uint64_t time_since_boot_sec; - DeviceLayer::DiagnosticDataMgr().GetUpTime(time_since_boot_sec); + DeviceLayer::GetDiagnosticDataProvider().GetUpTime(time_since_boot_sec); response.time_since_boot_millis = time_since_boot_sec * 1000; size_t count = 0; for (const FabricInfo & fabricInfo : Server::GetInstance().GetFabricTable()) diff --git a/src/platform/Tizen/PlatformManagerImpl.cpp b/src/platform/Tizen/PlatformManagerImpl.cpp index 7dced67d7a2178..d678f81fbc61ba 100644 --- a/src/platform/Tizen/PlatformManagerImpl.cpp +++ b/src/platform/Tizen/PlatformManagerImpl.cpp @@ -25,8 +25,8 @@ #include -#include #include +#include #include namespace chip { diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp index 839369d33630b9..7ac6665dcbdd26 100644 --- a/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.cpp @@ -21,17 +21,12 @@ * for Zephy platform. */ -#if !CONFIG_NORDIC_SECURITY_BACKEND -#include // nogncheck -#endif // !CONFIG_NORDIC_SECURITY_BACKEND - #include #include #include -#include +#include -#include #include namespace chip { diff --git a/src/platform/Zephyr/DiagnosticDataProviderImpl.h b/src/platform/Zephyr/DiagnosticDataProviderImpl.h index f58c6d712d81cf..6505cf5eedff17 100644 --- a/src/platform/Zephyr/DiagnosticDataProviderImpl.h +++ b/src/platform/Zephyr/DiagnosticDataProviderImpl.h @@ -42,17 +42,6 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider CHIP_ERROR GetCurrentHeapFree(uint64_t & currentHeapFree) override; CHIP_ERROR GetCurrentHeapUsed(uint64_t & currentHeapUsed) override; CHIP_ERROR GetCurrentHeapHighWatermark(uint64_t & currentHeapHighWatermark) override; - CHIP_ERROR GetThreadMetrics(ThreadMetrics ** threadMetricsOut) override; - void ReleaseThreadMetrics(ThreadMetrics * threadMetrics) override; - - CHIP_ERROR GetRebootCount(uint16_t & rebootCount) override; - CHIP_ERROR GetUpTime(uint64_t & upTime) override; - CHIP_ERROR GetTotalOperationalHours(uint32_t & totalOperationalHours) override; - CHIP_ERROR GetBootReason(uint8_t & bootReason) override; - - CHIP_ERROR GetActiveHardwareFaults(GeneralFaults & hardwareFaults) override; - CHIP_ERROR GetActiveRadioFaults(GeneralFaults & radioFaults) override; - CHIP_ERROR GetActiveNetworkFaults(GeneralFaults & networkFaults) override; }; } // namespace DeviceLayer diff --git a/src/platform/Zephyr/PlatformManagerImpl.cpp b/src/platform/Zephyr/PlatformManagerImpl.cpp index dab0812c135240..1efda5025fa61c 100644 --- a/src/platform/Zephyr/PlatformManagerImpl.cpp +++ b/src/platform/Zephyr/PlatformManagerImpl.cpp @@ -29,6 +29,7 @@ #include #include +#include #include #include @@ -73,6 +74,7 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void) err = Internal::ZephyrConfig::Init(); SuccessOrExit(err); SetConfigurationMgr(&ConfigurationManagerImpl::GetDefaultInstance()); + SetDiagnosticDataProvider(&DiagnosticDataProviderImpl::GetDefaultInstance()); #if !CONFIG_NORDIC_SECURITY_BACKEND // Add entropy source based on Zephyr entropy driver diff --git a/src/platform/nrfconnect/BUILD.gn b/src/platform/nrfconnect/BUILD.gn index de3d7de0afc6aa..d2296794185015 100644 --- a/src/platform/nrfconnect/BUILD.gn +++ b/src/platform/nrfconnect/BUILD.gn @@ -23,6 +23,8 @@ static_library("nrfconnect") { "../SingletonConfigurationManager.cpp", "../Zephyr/BLEManagerImpl.cpp", "../Zephyr/ConfigurationManagerImpl.cpp", + "../Zephyr/DiagnosticDataProviderImpl.cpp", + "../Zephyr/DiagnosticDataProviderImpl.h", "../Zephyr/KeyValueStoreManagerImpl.cpp", "../Zephyr/Logging.cpp", "../Zephyr/PlatformManagerImpl.cpp", @@ -39,8 +41,6 @@ static_library("nrfconnect") { "ConnectivityManagerImpl.h", "DeviceNetworkProvisioningDelegateImpl.cpp", "DeviceNetworkProvisioningDelegateImpl.h", - "DiagnosticDataProviderImpl.cpp", - "DiagnosticDataProviderImpl.h", "InetPlatformConfig.h", "KeyValueStoreManagerImpl.h", "PlatformManagerImpl.h", diff --git a/src/platform/nrfconnect/DiagnosticDataProviderImpl.cpp b/src/platform/nrfconnect/DiagnosticDataProviderImpl.cpp deleted file mode 100644 index 4a629b128e3a92..00000000000000 --- a/src/platform/nrfconnect/DiagnosticDataProviderImpl.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Provides an implementation of the DiagnosticDataProvider object - * for mbed platform. - */ - -#include - -#include -#include -#include - -namespace chip { -namespace DeviceLayer { - -DiagnosticDataProviderImpl & DiagnosticDataProviderImpl::GetDefaultInstance() -{ - static DiagnosticDataProviderImpl sInstance; - return sInstance; -} - -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/nrfconnect/DiagnosticDataProviderImpl.h b/src/platform/nrfconnect/DiagnosticDataProviderImpl.h deleted file mode 100644 index 731f445fec8671..00000000000000 --- a/src/platform/nrfconnect/DiagnosticDataProviderImpl.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Provides an implementation of the DiagnosticDataProvider object. - */ - -#pragma once - -#include - -namespace chip { -namespace DeviceLayer { - -/** - * Concrete implementation of the PlatformManager singleton object for Linux platforms. - */ -class DiagnosticDataProviderImpl : public DiagnosticDataProvider -{ -public: - static DiagnosticDataProviderImpl & GetDefaultInstance(); -}; - -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/telink/BUILD.gn b/src/platform/telink/BUILD.gn index bf9ce7345b355d..b4c5c22962ac3e 100644 --- a/src/platform/telink/BUILD.gn +++ b/src/platform/telink/BUILD.gn @@ -23,6 +23,8 @@ static_library("telink") { "../SingletonConfigurationManager.cpp", "../Zephyr/BLEManagerImpl.cpp", "../Zephyr/ConfigurationManagerImpl.cpp", + "../Zephyr/DiagnosticDataProviderImpl.cpp", + "../Zephyr/DiagnosticDataProviderImpl.h", "../Zephyr/KeyValueStoreManagerImpl.cpp", "../Zephyr/Logging.cpp", "../Zephyr/PlatformManagerImpl.cpp", @@ -39,8 +41,6 @@ static_library("telink") { "ConnectivityManagerImpl.h", "DeviceNetworkProvisioningDelegateImpl.cpp", "DeviceNetworkProvisioningDelegateImpl.h", - "DiagnosticDataProviderImpl.cpp", - "DiagnosticDataProviderImpl.h", "InetPlatformConfig.h", "KeyValueStoreManagerImpl.h", "PlatformManagerImpl.h", diff --git a/src/platform/telink/DiagnosticDataProviderImpl.cpp b/src/platform/telink/DiagnosticDataProviderImpl.cpp deleted file mode 100644 index 37a31a86f63951..00000000000000 --- a/src/platform/telink/DiagnosticDataProviderImpl.cpp +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Provides an implementation of the DiagnosticDataProvider object - * for telink platform. - */ - -#include - -#include -#include -#include - -namespace chip { -namespace DeviceLayer { - -DiagnosticDataProviderImpl & DiagnosticDataProviderImpl::GetDefaultInstance() -{ - static DiagnosticDataProviderImpl sInstance; - return sInstance; -} - -} // namespace DeviceLayer -} // namespace chip diff --git a/src/platform/telink/DiagnosticDataProviderImpl.h b/src/platform/telink/DiagnosticDataProviderImpl.h deleted file mode 100644 index 731f445fec8671..00000000000000 --- a/src/platform/telink/DiagnosticDataProviderImpl.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - * - * Copyright (c) 2021 Project CHIP Authors - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/** - * @file - * Provides an implementation of the DiagnosticDataProvider object. - */ - -#pragma once - -#include - -namespace chip { -namespace DeviceLayer { - -/** - * Concrete implementation of the PlatformManager singleton object for Linux platforms. - */ -class DiagnosticDataProviderImpl : public DiagnosticDataProvider -{ -public: - static DiagnosticDataProviderImpl & GetDefaultInstance(); -}; - -} // namespace DeviceLayer -} // namespace chip