Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / EFR32 / ConfigurationManagerImpl.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2019 Nest Labs, Inc.
5  *
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
9  *
10  *        http://www.apache.org/licenses/LICENSE-2.0
11  *
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.
17  */
18
19 /**
20  *    @file
21  *          Provides an implementation of the ConfigurationManager object
22  *          for EFR32 platforms using the Silicon Labs SDK.
23  */
24
25 #pragma once
26
27 #include <platform/internal/GenericConfigurationManagerImpl.h>
28
29 #include "EFR32Config.h"
30
31 namespace chip {
32 namespace DeviceLayer {
33
34 /**
35  * Concrete implementation of the ConfigurationManager singleton object for the EFR32 platform.
36  */
37 class ConfigurationManagerImpl final : public ConfigurationManager,
38                                        public Internal::GenericConfigurationManagerImpl<ConfigurationManagerImpl>,
39                                        private Internal::EFR32Config
40 {
41     // Allow the ConfigurationManager interface class to delegate method calls to
42     // the implementation methods provided by this class.
43     friend class ConfigurationManager;
44
45     // Allow the GenericConfigurationManagerImpl base class to access helper methods and types
46     // defined on this class.
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48     friend class Internal::GenericConfigurationManagerImpl<ConfigurationManagerImpl>;
49 #endif
50
51 private:
52     // ===== Members that implement the ConfigurationManager public interface.
53
54     CHIP_ERROR _Init(void);
55     CHIP_ERROR _GetPrimaryWiFiMACAddress(uint8_t * buf);
56     bool _CanFactoryReset(void);
57     void _InitiateFactoryReset(void);
58     CHIP_ERROR _ReadPersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t & value);
59     CHIP_ERROR _WritePersistedStorageValue(::chip::Platform::PersistedStorage::Key key, uint32_t value);
60
61     // NOTE: Other public interface methods are implemented by GenericConfigurationManagerImpl<>.
62
63     // ===== Members for internal use by the following friends.
64
65     friend ConfigurationManager & ConfigurationMgr(void);
66     friend ConfigurationManagerImpl & ConfigurationMgrImpl(void);
67
68     static ConfigurationManagerImpl sInstance;
69
70     // ===== Private members reserved for use by this class only.
71
72     static void DoFactoryReset(intptr_t arg);
73 };
74
75 /**
76  * Returns the public interface of the ConfigurationManager singleton object.
77  *
78  * Chip applications should use this to access features of the ConfigurationManager object
79  * that are common to all platforms.
80  */
81 inline ConfigurationManager & ConfigurationMgr(void)
82 {
83     return ConfigurationManagerImpl::sInstance;
84 }
85
86 /**
87  * Returns the platform-specific implementation of the ConfigurationManager singleton object.
88  *
89  * Chip applications can use this to gain access to features of the ConfigurationManager
90  * that are specific to the ESP32 platform.
91  */
92 inline ConfigurationManagerImpl & ConfigurationMgrImpl(void)
93 {
94     return ConfigurationManagerImpl::sInstance;
95 }
96
97 inline CHIP_ERROR ConfigurationManagerImpl::_GetPrimaryWiFiMACAddress(uint8_t * buf)
98 {
99     return CHIP_ERROR_UNSUPPORTED_CHIP_FEATURE;
100 }
101
102 } // namespace DeviceLayer
103 } // namespace chip