Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / ESP32 / PlatformManagerImpl.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *    Copyright (c) 2018 Nest Labs, Inc.
5  *    All rights reserved.
6  *
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
10  *
11  *        http://www.apache.org/licenses/LICENSE-2.0
12  *
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.
18  */
19
20 /**
21  *    @file
22  *          Provides an implementation of the PlatformManager object
23  *          for the ESP32 platform.
24  */
25
26 #pragma once
27
28 #include <platform/internal/GenericPlatformManagerImpl_FreeRTOS.h>
29
30 namespace chip {
31 namespace DeviceLayer {
32
33 /**
34  * Concrete implementation of the PlatformManager singleton object for the ESP32 platform.
35  */
36 class PlatformManagerImpl final : public PlatformManager, public Internal::GenericPlatformManagerImpl_FreeRTOS<PlatformManagerImpl>
37 {
38     // Allow the PlatformManager interface class to delegate method calls to
39     // the implementation methods provided by this class.
40     friend PlatformManager;
41
42     // Allow the generic implementation base class to call helper methods on
43     // this class.
44 #ifndef DOXYGEN_SHOULD_SKIP_THIS
45     friend Internal::GenericPlatformManagerImpl_FreeRTOS<PlatformManagerImpl>;
46 #endif
47
48 public:
49     // ===== Platform-specific members that may be accessed directly by the application.
50
51     CHIP_ERROR InitLwIPCoreLock(void);
52     static void HandleESPSystemEvent(void * arg, esp_event_base_t eventBase, int32_t eventId, void * eventData);
53
54 private:
55     // ===== Methods that implement the PlatformManager abstract interface.
56
57     CHIP_ERROR _InitChipStack(void);
58
59     // ===== Members for internal use by the following friends.
60
61     friend PlatformManager & PlatformMgr(void);
62     friend PlatformManagerImpl & PlatformMgrImpl(void);
63
64     static PlatformManagerImpl sInstance;
65 };
66
67 /**
68  * Returns the public interface of the PlatformManager singleton object.
69  *
70  * Chip applications should use this to access features of the PlatformManager object
71  * that are common to all platforms.
72  */
73 inline PlatformManager & PlatformMgr(void)
74 {
75     return PlatformManagerImpl::sInstance;
76 }
77
78 /**
79  * Returns the platform-specific implementation of the PlatformManager singleton object.
80  *
81  * Chip applications can use this to gain access to features of the PlatformManager
82  * that are specific to the ESP32 platform.
83  */
84 inline PlatformManagerImpl & PlatformMgrImpl(void)
85 {
86     return PlatformManagerImpl::sInstance;
87 }
88
89 } // namespace DeviceLayer
90 } // namespace chip