Fix for x86_64 build fail
[platform/upstream/connectedhomeip.git] / src / platform / Tizen / ThreadStackManagerImpl.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 <memory>
21 #include <thread>
22 #include <vector>
23
24 #include "platform/internal/CHIPDeviceLayerInternal.h"
25
26 #include "dbus/client/thread_api_dbus.hpp"
27 #include "platform/internal/DeviceNetworkInfo.h"
28
29 namespace chip {
30 namespace DeviceLayer {
31
32 class ThreadStackManagerImpl : public ThreadStackManager
33 {
34 public:
35     ThreadStackManagerImpl();
36
37     CHIP_ERROR _InitThreadStack();
38     void _ProcessThreadActivity();
39
40     CHIP_ERROR _StartThreadTask() { return CHIP_NO_ERROR; } // Intentionally left blank
41     void _LockThreadStack() {}                              // Intentionally left blank
42     bool _TryLockThreadStack() { return false; }            // Intentionally left blank
43     void _UnlockThreadStack() {}                            // Intentionally left blank
44
45     bool _HaveRouteToAddress(const Inet::IPAddress & destAddr);
46
47     void _OnPlatformEvent(const ChipDeviceEvent * event);
48
49     CHIP_ERROR _GetThreadProvision(Internal::DeviceNetworkInfo & netInfo, bool includeCredentials);
50
51     CHIP_ERROR _SetThreadProvision(const Internal::DeviceNetworkInfo & netInfo);
52
53     CHIP_ERROR _SetThreadProvision(const uint8_t * operationalDataset, size_t operationalDatasetLen);
54
55     void _ErasePersistentInfo();
56
57     bool _IsThreadProvisioned();
58
59     bool _IsThreadEnabled();
60
61     bool _IsThreadAttached();
62
63     CHIP_ERROR _SetThreadEnabled(bool val);
64
65     ConnectivityManager::ThreadDeviceType _GetThreadDeviceType();
66
67     CHIP_ERROR _SetThreadDeviceType(ConnectivityManager::ThreadDeviceType deviceType);
68
69     void _GetThreadPollingConfig(ConnectivityManager::ThreadPollingConfig & pollingConfig);
70
71     CHIP_ERROR _SetThreadPollingConfig(const ConnectivityManager::ThreadPollingConfig & pollingConfig);
72
73     bool _HaveMeshConnectivity();
74
75     void _OnMessageLayerActivityChanged(bool messageLayerIsActive);
76
77     void _OnCHIPoBLEAdvertisingStart();
78
79     void _OnCHIPoBLEAdvertisingStop();
80
81     CHIP_ERROR _GetAndLogThreadStatsCounters();
82
83     CHIP_ERROR _GetAndLogThreadTopologyMinimal();
84
85     CHIP_ERROR _GetAndLogThreadTopologyFull();
86
87     CHIP_ERROR _GetPrimary802154MACAddress(uint8_t * buf);
88
89     CHIP_ERROR _GetFactoryAssignedEUI64(uint8_t (&buf)[8]);
90
91     CHIP_ERROR _GetExternalIPv6Address(chip::Inet::IPAddress & addr);
92
93     CHIP_ERROR _JoinerStart();
94
95     ~ThreadStackManagerImpl() = default;
96
97     static ThreadStackManagerImpl sInstance;
98
99 private:
100     struct DBusConnectionDeleter
101     {
102         void operator()(DBusConnection * aConnection) { dbus_connection_unref(aConnection); }
103     };
104
105     using UniqueDBusConnection = std::unique_ptr<DBusConnection, DBusConnectionDeleter>;
106
107     void _ThreadDevcieRoleChangedHandler(otbr::DBus::DeviceRole role);
108
109     std::unique_ptr<otbr::DBus::ThreadApiDBus> mThreadApi;
110     UniqueDBusConnection mConnection;
111     std::vector<uint8_t> mOperationalDatasetTlv;
112     Internal::DeviceNetworkInfo mNetworkInfo;
113     bool mAttached;
114     std::thread mDBusEventLoop;
115 };
116
117 } // namespace DeviceLayer
118 } // namespace chip