3 * Copyright (c) 2020 Project CHIP Authors
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
9 * http://www.apache.org/licenses/LICENSE-2.0
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.
20 * Provides an implementation of the ThreadStackManager object for
26 #include <platform/OpenThread/GenericThreadStackManagerImpl_OpenThread.h>
28 #include <net/openthread.h>
31 #include <openthread/thread.h>
32 #include <platform/Zephyr/BLEManagerImpl.h>
34 #include <support/logging/CHIPLogging.h>
37 namespace DeviceLayer {
39 class ThreadStackManager;
40 class ThreadStackManagerImpl;
43 * Concrete implementation of the ThreadStackManager singleton object for nRF Connect platforms.
45 class ThreadStackManagerImpl final : public ThreadStackManager,
46 public Internal::GenericThreadStackManagerImpl_OpenThread<ThreadStackManagerImpl>
48 // Allow the ThreadStackManager interface class to delegate method calls to
49 // the implementation methods provided by this class.
50 friend class ThreadStackManager;
52 // namespace Internal {
54 // Allow the generic implementation base classes to call helper methods on
56 #ifndef DOXYGEN_SHOULD_SKIP_THIS
57 friend Internal::GenericThreadStackManagerImpl_OpenThread<ThreadStackManagerImpl>;
61 // ===== Methods that implement the ThreadStackManager abstract interface.
62 CHIP_ERROR _InitThreadStack();
65 // ===== Methods that implement the ThreadStackManager abstract interface.
67 CHIP_ERROR _StartThreadTask();
68 void _LockThreadStack();
69 bool _TryLockThreadStack();
70 void _UnlockThreadStack();
72 // ===== Methods that override the GenericThreadStackManagerImpl_OpenThread abstract interface.
74 void _ProcessThreadActivity();
75 void _OnCHIPoBLEAdvertisingStart();
76 void _OnCHIPoBLEAdvertisingStop();
78 //} // namespace Internal
81 // ===== Members for internal use by the following friends.
83 friend ThreadStackManager & ::chip::DeviceLayer::ThreadStackMgr(void);
84 friend ThreadStackManagerImpl & ::chip::DeviceLayer::ThreadStackMgrImpl(void);
86 static ThreadStackManagerImpl sInstance;
88 // ===== Private members for use by this class only.
90 ThreadStackManagerImpl() = default;
94 * Returns the public interface of the ThreadStackManager singleton object.
96 * chip applications should use this to access features of the ThreadStackManager object
97 * that are common to all platforms.
99 inline ThreadStackManager & ThreadStackMgr(void)
101 return ThreadStackManagerImpl::sInstance;
105 * Returns the platform-specific implementation of the ThreadStackManager singleton object.
107 * chip applications can use this to gain access to features of the ThreadStackManager
108 * that are specific to nRF Connect platforms.
110 inline ThreadStackManagerImpl & ThreadStackMgrImpl(void)
112 return ThreadStackManagerImpl::sInstance;
115 } // namespace DeviceLayer