Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / nrfconnect / ConnectivityManagerImpl.h
1 /*
2  *
3  *    Copyright (c) 2020 Project CHIP Authors
4  *
5  *    Licensed under the Apache License, Version 2.0 (the "License");
6  *    you may not use this file except in compliance with the License.
7  *    You may obtain a copy of the License at
8  *
9  *        http://www.apache.org/licenses/LICENSE-2.0
10  *
11  *    Unless required by applicable law or agreed to in writing, software
12  *    distributed under the License is distributed on an "AS IS" BASIS,
13  *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14  *    See the License for the specific language governing permissions and
15  *    limitations under the License.
16  */
17
18 #pragma once
19
20 #include <platform/ConnectivityManager.h>
21 #include <platform/internal/GenericConnectivityManagerImpl.h>
22 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
23 #include <platform/internal/GenericConnectivityManagerImpl_BLE.h>
24 #else
25 #include <platform/internal/GenericConnectivityManagerImpl_NoBLE.h>
26 #endif
27 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
28 #include <platform/internal/GenericConnectivityManagerImpl_Thread.h>
29 #else
30 #include <platform/internal/GenericConnectivityManagerImpl_NoThread.h>
31 #endif
32 #include <platform/internal/GenericConnectivityManagerImpl_NoWiFi.h>
33
34 #include <support/logging/CHIPLogging.h>
35
36 namespace chip {
37 namespace Inet {
38 class IPAddress;
39 } // namespace Inet
40 } // namespace chip
41
42 namespace chip {
43 namespace DeviceLayer {
44
45 /**
46  * Concrete implementation of the ConnectivityManager singleton object for Zephyr platforms.
47  */
48 class ConnectivityManagerImpl final : public ConnectivityManager,
49                                       public Internal::GenericConnectivityManagerImpl<ConnectivityManagerImpl>,
50 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
51                                       public Internal::GenericConnectivityManagerImpl_BLE<ConnectivityManagerImpl>,
52 #else
53                                       public Internal::GenericConnectivityManagerImpl_NoBLE<ConnectivityManagerImpl>,
54 #endif
55 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
56                                       public Internal::GenericConnectivityManagerImpl_Thread<ConnectivityManagerImpl>,
57 #else
58                                       public Internal::GenericConnectivityManagerImpl_NoThread<ConnectivityManagerImpl>,
59 #endif
60                                       public Internal::GenericConnectivityManagerImpl_NoWiFi<ConnectivityManagerImpl>
61 {
62     // Allow the ConnectivityManager interface class to delegate method calls to
63     // the implementation methods provided by this class.
64     friend class ConnectivityManager;
65
66 private:
67     // ===== Members that implement the ConnectivityManager abstract interface.
68
69     bool _HaveIPv4InternetConnectivity(void);
70     bool _HaveIPv6InternetConnectivity(void);
71     bool _HaveServiceConnectivity(void);
72     CHIP_ERROR _Init(void);
73     void _OnPlatformEvent(const ChipDeviceEvent * event);
74
75     // ===== Members for internal use by the following friends.
76
77     friend ConnectivityManager & ConnectivityMgr(void);
78     friend ConnectivityManagerImpl & ConnectivityMgrImpl(void);
79
80     static ConnectivityManagerImpl sInstance;
81 };
82
83 inline bool ConnectivityManagerImpl::_HaveIPv4InternetConnectivity(void)
84 {
85     return false;
86 }
87
88 inline bool ConnectivityManagerImpl::_HaveIPv6InternetConnectivity(void)
89 {
90     return false;
91 }
92
93 inline bool ConnectivityManagerImpl::_HaveServiceConnectivity(void)
94 {
95     return _HaveServiceConnectivityViaThread();
96 }
97
98 /**
99  * Returns the public interface of the ConnectivityManager singleton object.
100  *
101  * chip applications should use this to access features of the ConnectivityManager object
102  * that are common to all platforms.
103  */
104 inline ConnectivityManager & ConnectivityMgr(void)
105 {
106     return ConnectivityManagerImpl::sInstance;
107 }
108
109 /**
110  * Returns the platform-specific implementation of the ConnectivityManager singleton object.
111  *
112  * chip applications can use this to gain access to features of the ConnectivityManager
113  * that are specific to the ESP32 platform.
114  */
115 inline ConnectivityManagerImpl & ConnectivityMgrImpl(void)
116 {
117     return ConnectivityManagerImpl::sInstance;
118 }
119
120 } // namespace DeviceLayer
121 } // namespace chip