3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2018 Nest Labs, Inc.
7 * Licensed under the Apache License, Version 2.0 (the "License");
8 * you may not use this file except in compliance with the License.
9 * You may obtain a copy of the License at
11 * http://www.apache.org/licenses/LICENSE-2.0
13 * Unless required by applicable law or agreed to in writing, software
14 * distributed under the License is distributed on an "AS IS" BASIS,
15 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16 * See the License for the specific language governing permissions and
17 * limitations under the License.
22 * Provides the implementation of the Device Layer ConfigurationManager object
23 * for Darwin platforms.
26 #include <platform/internal/CHIPDeviceLayerInternal.h>
28 #include <core/CHIPVendorIdentifiers.hpp>
29 #include <platform/ConfigurationManager.h>
30 #include <platform/Darwin/PosixConfig.h>
31 #include <platform/internal/GenericConfigurationManagerImpl.cpp>
33 #include <support/CodeUtils.h>
34 #include <support/logging/CHIPLogging.h>
37 namespace DeviceLayer {
39 using namespace ::chip::DeviceLayer::Internal;
41 /** Singleton instance of the ConfigurationManager implementation object.
43 ConfigurationManagerImpl ConfigurationManagerImpl::sInstance;
45 CHIP_ERROR ConfigurationManagerImpl::_Init()
49 // Initialize the generic implementation base class.
50 err = Internal::GenericConfigurationManagerImpl<ConfigurationManagerImpl>::_Init();
57 CHIP_ERROR ConfigurationManagerImpl::_GetPrimaryWiFiMACAddress(uint8_t * buf)
59 // TODO(#739): add WiFi support
60 return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
63 bool ConfigurationManagerImpl::_CanFactoryReset()
65 // TODO(#742): query the application to determine if factory reset is allowed.
69 void ConfigurationManagerImpl::_InitiateFactoryReset()
71 ChipLogError(DeviceLayer, "InitiateFactoryReset not implemented");
74 CHIP_ERROR ConfigurationManagerImpl::_ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value)
76 PosixConfig::Key configKey{ kConfigNamespace_ChipCounters, key };
78 CHIP_ERROR err = ReadConfigValue(configKey, value);
79 if (err == CHIP_DEVICE_ERROR_CONFIG_NOT_FOUND)
81 err = CHIP_ERROR_PERSISTED_STORAGE_VALUE_NOT_FOUND;
86 CHIP_ERROR ConfigurationManagerImpl::_WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value)
88 PosixConfig::Key configKey{ kConfigNamespace_ChipCounters, key };
89 return WriteConfigValue(configKey, value);
92 } // namespace DeviceLayer