3 * Copyright (c) 2020 Project CHIP Authors
4 * Copyright (c) 2018 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>
42 namespace DeviceLayer {
45 * Concrete implementation of the ConnectivityManager singleton object for Darwin platforms.
47 class ConnectivityManagerImpl final : public ConnectivityManager,
48 #if CHIP_DEVICE_CONFIG_ENABLE_CHIPOBLE
49 public Internal::GenericConnectivityManagerImpl_BLE<ConnectivityManagerImpl>,
51 public Internal::GenericConnectivityManagerImpl_NoBLE<ConnectivityManagerImpl>,
53 #if CHIP_DEVICE_CONFIG_ENABLE_THREAD
54 public Internal::GenericConnectivityManagerImpl_Thread<ConnectivityManagerImpl>,
56 public Internal::GenericConnectivityManagerImpl_NoThread<ConnectivityManagerImpl>,
58 public Internal::GenericConnectivityManagerImpl_NoWiFi<ConnectivityManagerImpl>,
59 public Internal::GenericConnectivityManagerImpl<ConnectivityManagerImpl>
61 // Allow the ConnectivityManager interface class to delegate method calls to
62 // the implementation methods provided by this class.
63 friend class ConnectivityManager;
66 // ===== Members that implement the ConnectivityManager abstract interface.
68 bool _HaveIPv4InternetConnectivity(void);
69 bool _HaveIPv6InternetConnectivity(void);
70 bool _HaveServiceConnectivity(void);
71 CHIP_ERROR _Init(void);
72 void _OnPlatformEvent(const ChipDeviceEvent * event);
74 // ===== Members for internal use by the following friends.
76 friend ConnectivityManager & ConnectivityMgr(void);
77 friend ConnectivityManagerImpl & ConnectivityMgrImpl(void);
79 static ConnectivityManagerImpl sInstance;
82 inline bool ConnectivityManagerImpl::_HaveIPv4InternetConnectivity(void)
87 inline bool ConnectivityManagerImpl::_HaveIPv6InternetConnectivity(void)
92 inline bool ConnectivityManagerImpl::_HaveServiceConnectivity(void)
94 return _HaveServiceConnectivityViaThread();
98 * Returns the public interface of the ConnectivityManager singleton object.
100 * chip applications should use this to access features of the ConnectivityManager object
101 * that are common to all platforms.
103 inline ConnectivityManager & ConnectivityMgr(void)
105 return ConnectivityManagerImpl::sInstance;
109 * Returns the platform-specific implementation of the ConnectivityManager singleton object.
111 * chip applications can use this to gain access to features of the ConnectivityManager
112 * that are specific to the Darwin platform.
114 inline ConnectivityManagerImpl & ConnectivityMgrImpl(void)
116 return ConnectivityManagerImpl::sInstance;
119 } // namespace DeviceLayer