• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 2021-2022 Huawei Device Co., Ltd.
3  * Licensed under the Apache License, Version 2.0 (the "License");
4  * you may not use this file except in compliance with the License.
5  * You may obtain a copy of the License at
6  *
7  *     http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14  */
15 #ifndef OHOS_WIFI_DEVICE_IMPL_H
16 #define OHOS_WIFI_DEVICE_IMPL_H
17 
18 #include "wifi_device.h"
19 #include "wifi_device_proxy.h"
20 
21 namespace OHOS {
22 namespace Wifi {
23 class WifiDeviceImpl : public WifiDevice {
24 public:
25     explicit WifiDeviceImpl(int systemAbilityId);
26     ~WifiDeviceImpl();
27 
28     bool Init();
29 
30     /**
31      * @Description Turn on Wi-Fi
32      *
33      * @return ErrCode - operation result
34      */
35     ErrCode EnableWifi() override;
36 
37     /**
38      * @Description Turn off Wi-Fi
39      *
40      * @return ErrCode - operation result
41      */
42     ErrCode DisableWifi() override;
43 
44     /**
45      * @Description create the Wi-Fi protect.
46      *
47      * @param protectType - WifiProtectMode object
48      * @param protectName - the protect name
49      * @return ErrCode - operation result
50      */
51     ErrCode InitWifiProtect(const WifiProtectType &protectType, const std::string &protectName) override;
52 
53     /**
54      * @Description Acquire the Wi-Fi protect mode.
55      *
56      * @param protectMode - WifiProtectMode object
57      * @param protectName - the protect name
58      * @return ErrCode - operation result
59      */
60     ErrCode GetWifiProtectRef(const WifiProtectMode &protectMode, const std::string &protectName) override;
61 
62     /**
63      * @Description Release the Wi-Fi protect mode.
64      *
65      * @param protectName - the protect name
66      * @return ErrCode - operation result
67      */
68     ErrCode PutWifiProtectRef(const std::string &protectName) override;
69 
70     /**
71      * @Description Add a wifi device configuration.
72      *
73      * @param config - WifiDeviceConfig object
74      * @param result - the device configuration's network id
75      * @return ErrCode - operation result
76      */
77     ErrCode AddDeviceConfig(const WifiDeviceConfig &config, int &result) override;
78 
79     /**
80      * @Description Update a wifi device configuration.
81      *
82      * @param config - WifiDeviceConfig object
83      * @param result - the device configuration's network id after updated
84      * @return ErrCode - operation result
85      */
86     ErrCode UpdateDeviceConfig(const WifiDeviceConfig &config, int &result) override;
87 
88     /**
89      * @Description Remove the wifi device config equals to input network id
90      *
91      * @param networkId - want to remove device config's network id
92      * @return ErrCode - operation result
93      */
94     ErrCode RemoveDevice(int networkId) override;
95 
96     /**
97      * @Description Remove all device configs.
98      *
99      * @return ErrCode - operation result
100      */
101     ErrCode RemoveAllDevice() override;
102 
103     /**
104      * @Description Get all the device configs
105      *
106      * @param result - Get result vector of WifiDeviceConfig
107      * @return ErrCode - operation result
108      */
109     ErrCode GetDeviceConfigs(std::vector<WifiDeviceConfig> &result) override;
110 
111     /**
112      * @Description Connecting to a Specified Network
113      *
114      * @param networkId - network id
115      * @return ErrCode - operation result
116      */
117     ErrCode ConnectToNetwork(int networkId) override;
118 
119     /**
120      * @Description Connect To a network base WifiDeviceConfig object
121      *
122      * @param config - WifiDeviceConfig object
123      * @return ErrCode - operation result
124      */
125     ErrCode ConnectToDevice(const WifiDeviceConfig &config) override;
126 
127     /**
128      * @Description Check whether Wi-Fi is connected.
129      *
130      * @return bool - true: connected, false: not connected
131      */
132     bool IsConnected() override;
133 
134     /**
135      * @Description Disconnect
136      *
137      * @return ErrCode - operation result
138      */
139     ErrCode Disconnect(void) override;
140 
141     /**
142      * @Description Check whether Wi-Fi is active
143      *
144      * @param bActive - active / inactive
145      * @return ErrCode - operation result
146      */
147     ErrCode IsWifiActive(bool &bActive) override;
148 
149     /**
150      * @Description Get the Wifi State
151      *
152      * @param state - return current wifi state
153      * @return ErrCode - operation result
154      */
155     ErrCode GetWifiState(int &state) override;
156 
157     /**
158      * @Description Obtains the current Wi-Fi connection information
159      *
160      * @param info - WifiLinkedInfo object
161      * @return ErrCode - operation result
162      */
163     ErrCode GetLinkedInfo(WifiLinkedInfo &info) override;
164 
165     /**
166      * @Description Set the Country Code
167      *
168      * @param countryCode - country code
169      * @return ErrCode - operation result
170      */
171     ErrCode SetCountryCode(const std::string &countryCode) override;
172 
173     /**
174      * @Description Obtains the country code
175      *
176      * @param countryCode - output the country code
177      * @return ErrCode - operation result
178      */
179     ErrCode GetCountryCode(std::string &countryCode) override;
180 
181     /**
182      * @Description Register callback function.
183      *
184      * @param callback - IWifiDeviceCallBack object
185      * @return ErrCode - operation result
186      */
187     ErrCode RegisterCallBack(const sptr<IWifiDeviceCallBack> &callback) override;
188 
189     /**
190      * @Description Get the Signal Level object
191      *
192      * @param rssi - rssi
193      * @param band - band
194      * @param level - return the level
195      * @return ErrCode - operation result
196      */
197     ErrCode GetSignalLevel(const int &rssi, const int &band, int &level) override;
198 
199     /**
200      * @Description Get supported features
201      *
202      * @param features - return supported features
203      * @return ErrCode - operation result
204      */
205     ErrCode GetSupportedFeatures(long &features) override;
206 
207     /**
208      * @Description Check if supported input feature
209      *
210      * @param feature - input feature
211      * @return true - supported
212      * @return false - unsupported
213      */
214     bool IsFeatureSupported(long feature) override;
215 
216     /**
217      * @Description Enable device config, when set attemptEnable, disable other device config
218      *
219      * @param networkId - need enable device config's network id
220      * @param attemptEnable - if set true, disable other device config
221      * @return ErrCode - operation result
222      */
223     ErrCode EnableDeviceConfig(int networkId, bool attemptEnable) override;
224 
225     /**
226      * @Description Disable Wi-Fi device configuration.
227      *
228      * @param networkId - device config's network id
229      * @return ErrCode - operation result
230      */
231     ErrCode DisableDeviceConfig(int networkId) override;
232 
233     /**
234      * @Description Obtaining ip Request Information
235      *
236      * @param info - IpInfo object
237      * @return ErrCode - operation result
238      */
239     ErrCode GetIpInfo(IpInfo &info) override;
240 
241     /**
242      * @Description Reconnect to the currently active network
243      *
244      * @return ErrCode - operation result
245      */
246     ErrCode ReConnect() override;
247 
248     /**
249      * @Description ReAssociate network
250      *
251      * @return ErrCode - operation result
252      */
253     ErrCode ReAssociate() override;
254 
255     /**
256      * @Description Enable WPS connection
257      *
258      * @param config - WpsConfig object
259      * @return ErrCode - operation result
260      */
261     ErrCode StartWps(const WpsConfig &config);
262 
263     /**
264      * @Description Close the WPS connection
265      *
266      * @return ErrCode - operation result
267      */
268     ErrCode CancelWps(void);
269 
270     /**
271      * @Description  Get the device MAC address.
272      *
273      * @param result - Get device mac String
274      * @return ErrCode - operation result
275      */
276     ErrCode GetDeviceMacAddress(std::string &result) override;
277 
278     /**
279      * @Description set low latency mode
280      *
281      * @param enabled - true: enable low latency, false: disable low latency
282      * @return bool - operate result
283      */
284     bool SetLowLatencyMode(bool enabled) override;
285 
286 private:
287     int systemAbilityId_;
288     sptr<IWifiDevice> client_;
289 };
290 }  // namespace Wifi
291 }  // namespace OHOS
292 #endif