From b274b9ebe7ea9a89b9347b29b3be23ad2d18347c Mon Sep 17 00:00:00 2001 From: Boris Zbarsky Date: Mon, 11 Sep 2023 12:20:00 -0400 Subject: [PATCH] Implement RebootCount storage on Darwin. (#29134) * Implement RebootCount storage on Darwin. Fixes https://github.com/project-chip/connectedhomeip/issues/29108 * Address review comment. --- src/platform/Darwin/DiagnosticDataProviderImpl.cpp | 11 +++++++++++ src/platform/Darwin/DiagnosticDataProviderImpl.h | 1 + 2 files changed, 12 insertions(+) diff --git a/src/platform/Darwin/DiagnosticDataProviderImpl.cpp b/src/platform/Darwin/DiagnosticDataProviderImpl.cpp index 640a8eca27cd58..62a20a8efdb777 100644 --- a/src/platform/Darwin/DiagnosticDataProviderImpl.cpp +++ b/src/platform/Darwin/DiagnosticDataProviderImpl.cpp @@ -89,6 +89,17 @@ CHIP_ERROR DiagnosticDataProviderImpl::ResetWatermarks() return CHIP_NO_ERROR; } +CHIP_ERROR DiagnosticDataProviderImpl::GetRebootCount(uint16_t & rebootCount) +{ + uint32_t count = 0; + + ReturnErrorOnFailure(ConfigurationMgr().GetRebootCount(count)); + VerifyOrReturnError(count <= UINT16_MAX, CHIP_ERROR_INVALID_INTEGER_VALUE); + rebootCount = static_cast(count); + + return CHIP_NO_ERROR; +} + DiagnosticDataProvider & GetDiagnosticDataProviderImpl() { return DiagnosticDataProviderImpl::GetDefaultInstance(); diff --git a/src/platform/Darwin/DiagnosticDataProviderImpl.h b/src/platform/Darwin/DiagnosticDataProviderImpl.h index 3cfc31bc1f9678..b97aa30ad27074 100644 --- a/src/platform/Darwin/DiagnosticDataProviderImpl.h +++ b/src/platform/Darwin/DiagnosticDataProviderImpl.h @@ -43,6 +43,7 @@ class DiagnosticDataProviderImpl : public DiagnosticDataProvider // ===== Methods that implement the DiagnosticDataProvider abstract interface. bool SupportsWatermarks() override { return true; } CHIP_ERROR ResetWatermarks() override; + CHIP_ERROR GetRebootCount(uint16_t & rebootCount) override; }; /**