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 * Provides an implementation of the PlatformManager object.
27 #include <platform/internal/GenericPlatformManagerImpl_POSIX.h>
34 namespace DeviceLayer {
37 * Concrete implementation of the PlatformManager singleton object for Linux platforms.
39 class PlatformManagerImpl final : public PlatformManager, public Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>
41 // Allow the PlatformManager interface class to delegate method calls to
42 // the implementation methods provided by this class.
43 friend PlatformManager;
45 // Allow the generic implementation base class to call helper methods on
47 #ifndef DOXYGEN_SHOULD_SKIP_THIS
48 friend Internal::GenericPlatformManagerImpl_POSIX<PlatformManagerImpl>;
52 // ===== Platform-specific members that may be accessed directly by the application.
54 GDBusConnection * GetGDBusConnection();
58 // ===== Methods that implement the PlatformManager abstract interface.
60 CHIP_ERROR _InitChipStack();
62 // ===== Members for internal use by the following friends.
64 friend PlatformManager & PlatformMgr();
65 friend PlatformManagerImpl & PlatformMgrImpl();
66 friend class Internal::BLEManagerImpl;
68 static PlatformManagerImpl sInstance;
70 // The temporary hack for getting IP address change on linux for network provisioning in the rendezvous session.
71 // This should be removed or find a better place once we depercate the rendezvous session.
72 static void WiFIIPChangeListener();
75 struct GDBusConnectionDeleter
77 void operator()(GDBusConnection * conn) { g_object_unref(conn); }
79 using UniqueGDBusConnection = std::unique_ptr<GDBusConnection, GDBusConnectionDeleter>;
80 UniqueGDBusConnection mpGDBusConnection;
85 * Returns the public interface of the PlatformManager singleton object.
87 * chip applications should use this to access features of the PlatformManager object
88 * that are common to all platforms.
90 inline PlatformManager & PlatformMgr()
92 return PlatformManagerImpl::sInstance;
96 * Returns the platform-specific implementation of the PlatformManager singleton object.
98 * chip applications can use this to gain access to features of the PlatformManager
99 * that are specific to the ESP32 platform.
101 inline PlatformManagerImpl & PlatformMgrImpl()
103 return PlatformManagerImpl::sInstance;
106 } // namespace DeviceLayer