• 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_H
16 #define OHOS_WIFI_DEVICE_H
17 
18 #include "i_wifi_device_callback.h"
19 #include "wifi_errcode.h"
20 #include "wifi_msg.h"
21 
22 namespace OHOS {
23 namespace Wifi {
24 class WifiDevice {
25 public:
26     static std::unique_ptr<WifiDevice> CreateWifiDevice(int system_ability_id);
27 
28     static std::unique_ptr<WifiDevice> GetInstance(int system_ability_id);
29 
30     virtual ~WifiDevice();
31 
32     /**
33      * @Description Turn on Wi-Fi.
34      *
35      * @return ErrCode - operation result
36      */
37     virtual ErrCode EnableWifi() = 0;
38 
39     /**
40      * @Description Turn off Wi-Fi.
41      *
42      * @return ErrCode - operation result
43      */
44     virtual ErrCode DisableWifi() = 0;
45     /**
46      * @Description create the Wi-Fi protect.
47      *
48      * @param protectType - WifiProtectMode object
49      * @param protectName - the protect name
50      * @return ErrCode - operation result
51      */
52     virtual ErrCode InitWifiProtect(const WifiProtectType &protectType, const std::string &protectName) = 0;
53 
54     /**
55      * @Description Acquire the Wi-Fi protect mode.
56      *
57      * @param protectMode - WifiProtectMode object
58      * @param protectName - the protect name
59      * @return ErrCode - operation result
60      */
61     virtual ErrCode GetWifiProtectRef(const WifiProtectMode &protectMode, const std::string &protectName) = 0;
62 
63     /**
64      * @Description Release the Wi-Fi protect mode.
65      *
66      * @param protectName - the protect name
67      * @return ErrCode - operation result
68      */
69     virtual ErrCode PutWifiProtectRef(const std::string &protectName) = 0;
70 
71     /**
72      * @Description Add a wifi device configuration.
73      *
74      * @param config - WifiDeviceConfig object
75      * @param result - the device configuration's network id
76      * @return ErrCode - operation result
77      */
78     virtual ErrCode AddDeviceConfig(const WifiDeviceConfig &config, int &result) = 0;
79 
80     /**
81      * @Description Update a wifi device configuration.
82      *
83      * @param config - WifiDeviceConfig object
84      * @param result - the device configuration's network id after updated
85      * @return ErrCode - operation result
86      */
87     virtual ErrCode UpdateDeviceConfig(const WifiDeviceConfig &config, int &result) = 0;
88 
89     /**
90      * @Description Remove the wifi device config equals to input network id.
91      *
92      * @param networkId - want to remove device config's network id
93      * @return ErrCode - operation result
94      */
95     virtual ErrCode RemoveDevice(int networkId) = 0;
96 
97     /**
98      * @Description Remove all device configs.
99      *
100      * @return ErrCode - operation result
101      */
102     virtual ErrCode RemoveAllDevice() = 0;
103 
104     /**
105      * @Description Get all the device configs.
106      *
107      * @param result - Get result vector of WifiDeviceConfig
108      * @return ErrCode - operation result
109      */
110     virtual ErrCode GetDeviceConfigs(std::vector<WifiDeviceConfig> &result) = 0;
111 
112     /**
113      * @Description Connecting to a Specified Network.
114      *
115      * @param networkId - network id
116      * @return ErrCode - operation result
117      */
118     virtual ErrCode ConnectToNetwork(int networkId) = 0;
119 
120     /**
121      * @Description Connect To a network base WifiDeviceConfig object.
122      *
123      * @param config - WifiDeviceConfig object
124      * @return ErrCode - operation result
125      */
126     virtual ErrCode ConnectToDevice(const WifiDeviceConfig &config) = 0;
127 
128     /**
129      * @Description Check whether Wi-Fi is connected.
130      *
131      * @return bool - true: connected, false: not connected
132      */
133     virtual bool IsConnected() = 0;
134 
135     /**
136      * @Description Disconnect.
137      *
138      * @return ErrCode - operation result
139      */
140     virtual ErrCode Disconnect(void) = 0;
141 
142     /**
143      * @Description Check whether Wi-Fi is active.
144      *
145      * @param bActive - active / inactive
146      * @return ErrCode - operation result
147      */
148     virtual ErrCode IsWifiActive(bool &bActive) = 0;
149 
150     /**
151      * @Description Get the Wi-Fi State.
152      *
153      * @param state - return current wifi state
154      * @return ErrCode - operation result
155      */
156     virtual ErrCode GetWifiState(int &state) = 0;
157 
158     /**
159      * @Description Obtains the current Wi-Fi connection information.
160      *
161      * @param info - WifiLinkedInfo object
162      * @return ErrCode - operation result
163      */
164     virtual ErrCode GetLinkedInfo(WifiLinkedInfo &info) = 0;
165 
166     /**
167      * @Description Set the country code.
168      *
169      * @param countryCode - country code
170      * @return ErrCode - operation result
171      */
172     virtual ErrCode SetCountryCode(const std::string &countryCode) = 0;
173 
174     /**
175      * @Description Obtains the country code.
176      *
177      * @param countryCode - output the country code
178      * @return ErrCode - operation result
179      */
180     virtual ErrCode GetCountryCode(std::string &countryCode) = 0;
181 
182     /**
183      * @Description Register callback function.
184      *
185      * @param callback - IWifiDeviceCallBack object
186      * @return ErrCode - operation result
187      */
188     virtual ErrCode RegisterCallBack(const sptr<IWifiDeviceCallBack> &callback) = 0;
189 
190     /**
191      * @Description Get the signal level object.
192      *
193      * @param rssi - rssi
194      * @param band - band
195      * @param level - return the level
196      * @return ErrCode - operation result
197      */
198     virtual ErrCode GetSignalLevel(const int &rssi, const int &band, int &level) = 0;
199 
200     /**
201      * @Description Get supported features
202      *
203      * @param features - return supported features
204      * @return ErrCode - operation result
205      */
206     virtual ErrCode GetSupportedFeatures(long &features) = 0;
207 
208     /**
209      * @Description Check if supported input feature
210      *
211      * @param feature - input feature
212      * @return true - supported
213      * @return false - unsupported
214      */
215     virtual bool IsFeatureSupported(long feature) = 0;
216 
217     /**
218      * @Description Enable device config, when set attemptEnable, disable other device config
219      *
220      * @param networkId - need enable device config's network id
221      * @param attemptEnable - if set true, disable other device config
222      * @return ErrCode - operation result
223      */
224     virtual ErrCode EnableDeviceConfig(int networkId, bool attemptEnable) = 0;
225 
226     /**
227      * @Description Disable Wi-Fi device configuration.
228      *
229      * @param networkId - device config's network id
230      * @return ErrCode - operation result
231      */
232     virtual ErrCode DisableDeviceConfig(int networkId) = 0;
233 
234     /**
235      * @Description Obtaining ip Request Information
236      *
237      * @param info - IpInfo object
238      * @return ErrCode - operation result
239      */
240     virtual ErrCode GetIpInfo(IpInfo &info) = 0;
241 
242     /**
243      * @Description Reconnect to the currently active network
244      *
245      * @return ErrCode - operation result
246      */
247     virtual ErrCode ReConnect() = 0;
248 
249     /**
250      * @Description ReAssociate network
251      *
252      * @return ErrCode - operation result
253      */
254     virtual ErrCode ReAssociate() = 0;
255 
256     /**
257      * @Description  Get the device MAC address.
258      *
259      * @param result - Get device mac String
260      * @return ErrCode - operation result
261      */
262     virtual ErrCode GetDeviceMacAddress(std::string &result) = 0;
263 
264     /**
265      * @Description set low latency mode
266      *
267      * @param enabled - true: enable low latency, false: disable low latency
268      * @return bool - operate result
269      */
270     virtual bool SetLowLatencyMode(bool enabled) = 0;
271 };
272 }  // namespace Wifi
273 }  // namespace OHOS
274 #endif