3 * Copyright (c) 2020 Project CHIP Authors
6 * Licensed under the Apache License, Version 2.0 (the "License");
7 * you may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
10 * http://www.apache.org/licenses/LICENSE-2.0
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
21 * This file defines a class for managing client application
22 * user-editable settings. CHIP settings are partitioned into two
25 * 1. immutable / durable: factory parameters (CHIP_DEFAULT_FACTORY_PATH)
26 * 2. mutable / ephemeral: user parameters (CHIP_DEFAULT_CONFIG_PATH/CHIP_DEFAULT_DATA_PATH)
28 * The ephemeral partition should be erased during factory reset.
30 * ChipLinuxStorage wraps the storage class ChipLinuxStorageIni with mutex.
37 #include <platform/Linux/CHIPLinuxStorageIni.h>
40 #define FATCONFDIR "/tmp"
44 #define SYSCONFDIR "/tmp"
48 #define LOCALSTATEDIR "/tmp"
51 #define CHIP_DEFAULT_FACTORY_PATH \
54 #define CHIP_DEFAULT_CONFIG_PATH \
57 #define CHIP_DEFAULT_DATA_PATH \
62 namespace DeviceLayer {
65 class ChipLinuxStorage : private ChipLinuxStorageIni
71 CHIP_ERROR Init(const char * configFile);
72 CHIP_ERROR ReadValue(const char * key, bool & val);
73 CHIP_ERROR ReadValue(const char * key, uint32_t & val);
74 CHIP_ERROR ReadValue(const char * key, uint64_t & val);
75 CHIP_ERROR ReadValueStr(const char * key, char * buf, size_t bufSize, size_t & outLen);
76 CHIP_ERROR ReadValueBin(const char * key, uint8_t * buf, size_t bufSize, size_t & outLen);
77 CHIP_ERROR WriteValue(const char * key, bool val);
78 CHIP_ERROR WriteValue(const char * key, uint32_t val);
79 CHIP_ERROR WriteValue(const char * key, uint64_t val);
80 CHIP_ERROR WriteValueStr(const char * key, const char * val);
81 CHIP_ERROR WriteValueBin(const char * key, const uint8_t * data, size_t dataLen);
82 CHIP_ERROR ClearValue(const char * key);
83 CHIP_ERROR ClearAll();
85 bool HasValue(const char * key);
90 std::string mConfigPath;
93 } // namespace Internal
94 } // namespace DeviceLayer