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