/* * Copyright (c) 2022 Project CHIP Authors * All rights reserved. * * 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. */ #include #include #include #include namespace chip { namespace DeviceLayer { PlatformManagerImpl PlatformManagerImpl::sInstance; void PlatformManagerImpl::_Shutdown() { uint64_t upTime = 0; if (GetDiagnosticDataProvider().GetUpTime(upTime) == CHIP_NO_ERROR) { uint32_t totalOperationalHours = 0; if (ConfigurationMgr().GetTotalOperationalHours(totalOperationalHours) == CHIP_NO_ERROR) { ConfigurationMgr().StoreTotalOperationalHours(totalOperationalHours + static_cast(upTime / 3600)); } else { ChipLogError(DeviceLayer, "Failed to get total operational hours of the Node"); } } else { ChipLogError(DeviceLayer, "Failed to get current uptime since the Node’s last reboot"); } Internal::GenericPlatformManagerImpl_FreeRTOS::_Shutdown(); } CHIP_ERROR PlatformManagerImpl::_PostEvent(const ChipDeviceEvent * event) { if (mChipEventQueue == NULL) { return CHIP_ERROR_INTERNAL; } BaseType_t status = xQueueSend(mChipEventQueue, event, 0); if (status != pdTRUE) { ChipLogError(DeviceLayer, "Failed to post event to CHIP Platform event queue"); return CHIP_ERROR(chip::ChipError::Range::kOS, status); } return CHIP_NO_ERROR; } } // namespace DeviceLayer } // namespace chip