Skip to content

Commit b1568d4

Browse files
committed
fix total operation hours value get incorrect
1 parent bfc4bac commit b1568d4

File tree

2 files changed

+5
-27
lines changed

2 files changed

+5
-27
lines changed

src/platform/ESP32/DiagnosticDataProviderImpl.cpp

+1-14
Original file line numberDiff line numberDiff line change
@@ -156,20 +156,7 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetUpTime(uint64_t & upTime)
156156

157157
CHIP_ERROR DiagnosticDataProviderImpl::GetTotalOperationalHours(uint32_t & totalOperationalHours)
158158
{
159-
uint64_t upTime = 0;
160-
161-
if (GetUpTime(upTime) == CHIP_NO_ERROR)
162-
{
163-
uint32_t totalHours = 0;
164-
if (ConfigurationMgr().GetTotalOperationalHours(totalHours) == CHIP_NO_ERROR)
165-
{
166-
VerifyOrReturnError(upTime / 3600 <= UINT32_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE);
167-
totalOperationalHours = totalHours + static_cast<uint32_t>(upTime / 3600);
168-
return CHIP_NO_ERROR;
169-
}
170-
}
171-
172-
return CHIP_ERROR_INVALID_TIME;
159+
return ConfigurationMgr().GetTotalOperationalHours(totalOperationalHours);
173160
}
174161

175162
CHIP_ERROR DiagnosticDataProviderImpl::GetBootReason(BootReasonType & bootReason)

src/platform/ESP32/PlatformManagerImpl.cpp

+4-13
Original file line numberDiff line numberDiff line change
@@ -85,24 +85,15 @@ CHIP_ERROR PlatformManagerImpl::_InitChipStack(void)
8585

8686
void PlatformManagerImpl::_Shutdown()
8787
{
88-
uint64_t upTime = 0;
88+
uint32_t totalOperationalHours = 0;
8989

90-
if (GetDiagnosticDataProvider().GetUpTime(upTime) == CHIP_NO_ERROR)
90+
if (ConfigurationMgr().GetTotalOperationalHours(totalOperationalHours) == CHIP_NO_ERROR)
9191
{
92-
uint32_t totalOperationalHours = 0;
93-
94-
if (ConfigurationMgr().GetTotalOperationalHours(totalOperationalHours) == CHIP_NO_ERROR)
95-
{
96-
ConfigurationMgr().StoreTotalOperationalHours(totalOperationalHours + static_cast<uint32_t>(upTime / 3600));
97-
}
98-
else
99-
{
100-
ChipLogError(DeviceLayer, "Failed to get total operational hours of the Node");
101-
}
92+
ConfigurationMgr().StoreTotalOperationalHours(totalOperationalHours);
10293
}
10394
else
10495
{
105-
ChipLogError(DeviceLayer, "Failed to get current uptime since the Node’s last reboot");
96+
ChipLogError(DeviceLayer, "Failed to get total operational hours of the Node");
10697
}
10798

10899
Internal::GenericPlatformManagerImpl_FreeRTOS<PlatformManagerImpl>::_Shutdown();

0 commit comments

Comments
 (0)