3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2019 Nest Labs, Inc.
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 #include <platform/ConnectivityManager.h>
22 #include <platform/internal/GenericConnectivityManagerImpl.h>
23 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
24 #include <platform/internal/GenericConnectivityManagerImpl_BLE.h>
26 #include <platform/internal/GenericConnectivityManagerImpl_NoBLE.h>
28 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
29 #include <platform/internal/GenericConnectivityManagerImpl_Thread.h>
31 #include <platform/internal/GenericConnectivityManagerImpl_NoThread.h>
33 #include <platform/internal/GenericConnectivityManagerImpl_NoWiFi.h>
40 namespace DeviceLayer {
43 * Concrete implementation of the ConnectivityManager singleton object for Silicon Labs EFR32 platforms.
45 class ConnectivityManagerImpl final : public ConnectivityManager,
46 public Internal::GenericConnectivityManagerImpl<ConnectivityManagerImpl>,
47 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
48 public Internal::GenericConnectivityManagerImpl_BLE<ConnectivityManagerImpl>,
50 public Internal::GenericConnectivityManagerImpl_NoBLE<ConnectivityManagerImpl>,
52 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
53 public Internal::GenericConnectivityManagerImpl_Thread<ConnectivityManagerImpl>,
55 public Internal::GenericConnectivityManagerImpl_NoThread<ConnectivityManagerImpl>,
57 public Internal::GenericConnectivityManagerImpl_NoWiFi<ConnectivityManagerImpl>
59 // Allow the ConnectivityManager interface class to delegate method calls to
60 // the implementation methods provided by this class.
61 friend class ConnectivityManager;
64 // ===== Members that implement the ConnectivityManager abstract interface.
66 bool _HaveIPv4InternetConnectivity(void);
67 bool _HaveIPv6InternetConnectivity(void);
68 bool _HaveServiceConnectivity(void);
69 CHIP_ERROR _Init(void);
70 void _OnPlatformEvent(const ChipDeviceEvent * event);
72 // ===== Members for internal use by the following friends.
74 friend ConnectivityManager & ConnectivityMgr(void);
75 friend ConnectivityManagerImpl & ConnectivityMgrImpl(void);
77 static ConnectivityManagerImpl sInstance;
80 inline bool ConnectivityManagerImpl::_HaveIPv4InternetConnectivity(void)
85 inline bool ConnectivityManagerImpl::_HaveIPv6InternetConnectivity(void)
90 inline bool ConnectivityManagerImpl::_HaveServiceConnectivity(void)
92 return _HaveServiceConnectivityViaThread();
96 * Returns the public interface of the ConnectivityManager singleton object.
98 * Chip applications should use this to access features of the ConnectivityManager object
99 * that are common to all platforms.
101 inline ConnectivityManager & ConnectivityMgr(void)
103 return ConnectivityManagerImpl::sInstance;
107 * Returns the platform-specific implementation of the ConnectivityManager singleton object.
109 * Chip applications can use this to gain access to features of the ConnectivityManager
110 * that are specific to the ESP32 platform.
112 inline ConnectivityManagerImpl & ConnectivityMgrImpl(void)
114 return ConnectivityManagerImpl::sInstance;
117 } // namespace DeviceLayer