Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / EFR32 / ConnectivityManagerImpl.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 #pragma once
20
21 #include <platform/ConnectivityManager.h>
22 #include <platform/internal/GenericConnectivityManagerImpl.h>
23 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
24 #include <platform/internal/GenericConnectivityManagerImpl_BLE.h>
25 #else
26 #include <platform/internal/GenericConnectivityManagerImpl_NoBLE.h>
27 #endif
28 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
29 #include <platform/internal/GenericConnectivityManagerImpl_Thread.h>
30 #else
31 #include <platform/internal/GenericConnectivityManagerImpl_NoThread.h>
32 #endif
33 #include <platform/internal/GenericConnectivityManagerImpl_NoWiFi.h>
34
35 namespace Inet {
36 class IPAddress;
37 } // namespace Inet
38
39 namespace chip {
40 namespace DeviceLayer {
41
42 /**
43  * Concrete implementation of the ConnectivityManager singleton object for Silicon Labs EFR32 platforms.
44  */
45 class ConnectivityManagerImpl final : public ConnectivityManager,
46                                       public Internal::GenericConnectivityManagerImpl<ConnectivityManagerImpl>,
47 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
48                                       public Internal::GenericConnectivityManagerImpl_BLE<ConnectivityManagerImpl>,
49 #else
50                                       public Internal::GenericConnectivityManagerImpl_NoBLE<ConnectivityManagerImpl>,
51 #endif
52 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
53                                       public Internal::GenericConnectivityManagerImpl_Thread<ConnectivityManagerImpl>,
54 #else
55                                       public Internal::GenericConnectivityManagerImpl_NoThread<ConnectivityManagerImpl>,
56 #endif
57                                       public Internal::GenericConnectivityManagerImpl_NoWiFi<ConnectivityManagerImpl>
58 {
59     // Allow the ConnectivityManager interface class to delegate method calls to
60     // the implementation methods provided by this class.
61     friend class ConnectivityManager;
62
63 private:
64     // ===== Members that implement the ConnectivityManager abstract interface.
65
66     bool _HaveIPv4InternetConnectivity(void);
67     bool _HaveIPv6InternetConnectivity(void);
68     bool _HaveServiceConnectivity(void);
69     CHIP_ERROR _Init(void);
70     void _OnPlatformEvent(const ChipDeviceEvent * event);
71
72     // ===== Members for internal use by the following friends.
73
74     friend ConnectivityManager & ConnectivityMgr(void);
75     friend ConnectivityManagerImpl & ConnectivityMgrImpl(void);
76
77     static ConnectivityManagerImpl sInstance;
78 };
79
80 inline bool ConnectivityManagerImpl::_HaveIPv4InternetConnectivity(void)
81 {
82     return false;
83 }
84
85 inline bool ConnectivityManagerImpl::_HaveIPv6InternetConnectivity(void)
86 {
87     return false;
88 }
89
90 inline bool ConnectivityManagerImpl::_HaveServiceConnectivity(void)
91 {
92     return _HaveServiceConnectivityViaThread();
93 }
94
95 /**
96  * Returns the public interface of the ConnectivityManager singleton object.
97  *
98  * Chip applications should use this to access features of the ConnectivityManager object
99  * that are common to all platforms.
100  */
101 inline ConnectivityManager & ConnectivityMgr(void)
102 {
103     return ConnectivityManagerImpl::sInstance;
104 }
105
106 /**
107  * Returns the platform-specific implementation of the ConnectivityManager singleton object.
108  *
109  * Chip applications can use this to gain access to features of the ConnectivityManager
110  * that are specific to the ESP32 platform.
111  */
112 inline ConnectivityManagerImpl & ConnectivityMgrImpl(void)
113 {
114     return ConnectivityManagerImpl::sInstance;
115 }
116
117 } // namespace DeviceLayer
118 } // namespace chip