Skip to content

Commit

Permalink
[Zephyr] Save total operational hours on Read
Browse files Browse the repository at this point in the history
Currently total operational hours are saved to NVM with
`CONFIG_CHIP_OPERATIONAL_TIME_SAVE_INTERVAL`.
Certification tests require checking the value after 1 hour,
restarting the DUT, and checking if the value has not changed,
causing failures if given config is higher than 1.

This commit additionaly saves total operational hours to NVM
everytime it is being read by `GetTotalOperationalHours`
(writing only if currently stored value should be updated).
This way value is stored with minimum frequency of 1 hour (if
read request is sent frequently) and maximum frequency of
`CONFIG_CHIP_OPERATIONAL_TIME_SAVE_INTERVAL`.
  • Loading branch information
maciejbaczmanski committed Jan 28, 2025
1 parent b082219 commit 4bd171f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/platform/Zephyr/DiagnosticDataProviderImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,11 @@ CHIP_ERROR DiagnosticDataProviderImpl::GetTotalOperationalHours(uint32_t & total

totalOperationalHours = static_cast<uint32_t>(totalHours + deltaTime < UINT32_MAX ? totalHours + deltaTime : UINT32_MAX);

if (deltaTime > 0) {
ReturnErrorOnFailure(ConfigurationMgr().StoreTotalOperationalHours(totalOperationalHours));
PlatformMgrImpl().SetSavedOperationalHoursSinceBoot(upTimeH);
}

return CHIP_NO_ERROR;
}

Expand Down
1 change: 1 addition & 0 deletions src/platform/Zephyr/PlatformManagerImpl.h
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@ class PlatformManagerImpl final : public PlatformManager, public Internal::Gener

System::Clock::Timestamp GetStartTime() { return mStartTime; }
uint32_t GetSavedOperationalHoursSinceBoot() { return mSavedOperationalHoursSinceBoot; }
void SetSavedOperationalHoursSinceBoot(uint32_t hours) { mSavedOperationalHoursSinceBoot = hours; }

private:
// ===== Methods that implement the PlatformManager abstract interface.
Expand Down

0 comments on commit 4bd171f

Please sign in to comment.