1 /* 2 * Copyright (C) 2021 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 16 #ifndef OHOS_WIFI_STA_HAL_INTERFACE_H 17 #define OHOS_WIFI_STA_HAL_INTERFACE_H 18 19 #include <string> 20 #include <vector> 21 #include "wifi_base_hal_interface.h" 22 #include "wifi_event_callback.h" 23 #include "wifi_idl_struct.h" 24 #include "wifi_scan_param.h" 25 #include "wifi_idl_define.h" 26 27 namespace OHOS { 28 namespace Wifi { 29 class WifiStaHalInterface : public WifiBaseHalInterface { 30 public: 31 /** 32 * @Description Get the Instance object. 33 * 34 * @return WifiStaHalInterface& 35 */ 36 static WifiStaHalInterface &GetInstance(void); 37 38 /** 39 * @Description Open Wifi. 40 * 41 * @return WifiErrorNo 42 */ 43 WifiErrorNo StartWifi(void); 44 45 /** 46 * @Description Close Wifi. 47 * 48 * @return WifiErrorNo 49 */ 50 WifiErrorNo StopWifi(void); 51 52 /** 53 * @Description Connect Wifi. 54 * 55 * @param networkId 56 * @return WifiErrorNo 57 */ 58 WifiErrorNo Connect(int networkId); 59 60 /** 61 * @Description Reconnect Wifi. 62 * 63 * @return WifiErrorNo 64 */ 65 WifiErrorNo Reconnect(void); 66 67 /** 68 * @Description Reassociate Wifi. 69 * 70 * @return WifiErrorNo 71 */ 72 WifiErrorNo Reassociate(void); 73 74 /** 75 * @Description Disconnect Wifi. 76 * 77 * @return WifiErrorNo 78 */ 79 WifiErrorNo Disconnect(void); 80 81 /** 82 * @Description Obtaining the STA Support Capability. 83 * 84 * @param capabilities 85 * @return WifiErrorNo 86 */ 87 WifiErrorNo GetStaCapabilities(unsigned int &capabilities); 88 89 /** 90 * @Description Obtaining the MAC Address of a STA. 91 * 92 * @param mac 93 * @return WifiErrorNo 94 */ 95 WifiErrorNo GetStaDeviceMacAddress(std::string &mac); 96 97 /** 98 * @Description Obtains the frequencies supported by a specified frequency band. 99 * 100 * @param band 101 * @param frequencies 102 * @return WifiErrorNo 103 */ 104 WifiErrorNo GetSupportFrequencies(int band, std::vector<int> &frequencies); 105 106 /** 107 * @Description Sets the MAC address of the Wi-Fi connection. 108 * 109 * @param mac 110 * @return WifiErrorNo 111 */ 112 WifiErrorNo SetConnectMacAddr(const std::string &mac); 113 114 /** 115 * @Description Sets the MAC address for Wi-Fi scanning. 116 * 117 * @param mac 118 * @return WifiErrorNo 119 */ 120 WifiErrorNo SetScanMacAddress(const std::string &mac); 121 122 /** 123 * @Description Disconnect the BSSID of the last roaming subscriber. 124 * 125 * @param mac 126 * @return WifiErrorNo 127 */ 128 WifiErrorNo DisconnectLastRoamingBssid(const std::string &mac); 129 130 /** 131 * @Description Get total supported feature, and call user can 132 * determine whether support a feature. 133 * 134 * @param feature 135 * @return WifiErrorNo 136 */ 137 WifiErrorNo GetSupportFeature(long &feature); 138 139 /** 140 * @Description Send instructions to the Wi-Fi driver or chip. 141 * 142 * @param request 143 * @return WifiErrorNo 144 */ 145 WifiErrorNo SendRequest(const WifiStaRequest &request); 146 147 /** 148 * @Description Set the Wi-Fi transmit power. 149 * 150 * @param power 151 * @return WifiErrorNo 152 */ 153 WifiErrorNo SetTxPower(int power); 154 155 /** 156 * @Description Scan by specified parameter. 157 * 158 * @param scanParam 159 * @return WifiErrorNo 160 */ 161 WifiErrorNo Scan(const WifiScanParam &scanParam); 162 163 /** 164 * @Description Obtain the scanning result. 165 * 166 * @param scanResults 167 * @return WifiErrorNo 168 */ 169 WifiErrorNo QueryScanInfos(std::vector<InterScanInfo> &scanInfos); 170 171 /** 172 * @Description Initiate PNO scanning. 173 * 174 * @param scanParam 175 * @return WifiErrorNo 176 */ 177 WifiErrorNo StartPnoScan(const WifiPnoScanParam &scanParam); 178 179 /** 180 * @Description Stop PNO Scanning. 181 * 182 * @return WifiErrorNo 183 */ 184 WifiErrorNo StopPnoScan(void); 185 186 /** 187 * @Description Deleting a Network. 188 * 189 * @param networkId 190 * @return WifiErrorNo 191 */ 192 WifiErrorNo RemoveDevice(int networkId); 193 194 /** 195 * @Description Clears the network configuration information saved by wpa_supplicant. 196 * 197 * @return WifiErrorNo 198 */ 199 WifiErrorNo ClearDeviceConfig(void) const; 200 201 /** 202 * @Description Request to obtain the next network ID. 203 * 204 * @param networkId 205 * @return WifiErrorNo 206 */ 207 WifiErrorNo GetNextNetworkId(int &networkId); 208 209 /** 210 * @Description Enable a network. 211 * 212 * @param networkId 213 * @return WifiErrorNo 214 */ 215 WifiErrorNo EnableNetwork(int networkId); 216 217 /** 218 * @Description Disable a network. 219 * 220 * @param networkId 221 * @return WifiErrorNo 222 */ 223 WifiErrorNo DisableNetwork(int networkId); 224 225 /** 226 * @Description Setting the network. 227 * 228 * @param networkId 229 * @param config 230 * @return WifiErrorNo 231 */ 232 WifiErrorNo SetDeviceConfig(int networkId, const WifiIdlDeviceConfig &config); 233 234 /** 235 * @Description Obtaining Network Configurations. 236 * 237 * @param config 238 * @return WifiErrorNo 239 */ 240 WifiErrorNo GetDeviceConfig(WifiIdlGetDeviceConfig &config); 241 242 /** 243 * @Description Save network config. 244 * 245 * @return WifiErrorNo 246 */ 247 WifiErrorNo SaveDeviceConfig(void); 248 249 /** 250 * @Description Registering the Sta Event Callback. 251 * 252 * @param callback 253 * @return WifiErrorNo 254 */ 255 WifiErrorNo RegisterStaEventCallback(const WifiEventCallback &callback); 256 257 /** 258 * @Description Enabling WPS in PBC Mode. 259 * 260 * @param config 261 * @return WifiErrorNo 262 */ 263 WifiErrorNo StartWpsPbcMode(const WifiIdlWpsConfig &config); 264 265 /** 266 * @Description Enable PIN mode WPS. 267 * 268 * @param config 269 * @param pinCode 270 * @return WifiErrorNo 271 */ 272 WifiErrorNo StartWpsPinMode(const WifiIdlWpsConfig &config, int &pinCode); 273 274 /** 275 * @Description Close wps. 276 * 277 * @return WifiErrorNo 278 */ 279 WifiErrorNo StopWps(void); 280 281 /** 282 * @Description Obtains the roaming support capability. 283 * 284 * @param capability 285 * @return WifiErrorNo 286 */ 287 WifiErrorNo GetRoamingCapabilities(WifiIdlRoamCapability &capability); 288 289 /** 290 * @Description Set bssid to supplicant. 291 * 292 * @param networkId 293 * @param bssid 294 * @return WifiErrorNo 295 */ 296 WifiErrorNo SetWpsBssid(int networkId, const std::string &bssid); 297 298 /** 299 * @Description Setting Roaming Configurations. 300 * 301 * @param config 302 * @return WifiErrorNo 303 */ 304 WifiErrorNo SetRoamConfig(const WifiIdlRoamConfig &config); 305 306 /** 307 * @Description Wpa_s disable/enable(0/1) automatic reconnection. 308 * 309 * @param enable 310 * @return WifiErrorNo 311 */ 312 WifiErrorNo WpaAutoConnect(int enable); 313 314 /** 315 * @Description Clearing the wpa Blocklist. 316 * 317 * @return WifiErrorNo 318 */ 319 WifiErrorNo WpaBlocklistClear(); 320 321 /** 322 * @Description Obtaining the Network List. 323 * 324 * @param networkList 325 * @return WifiErrorNo 326 */ 327 WifiErrorNo GetNetworkList(std::vector<WifiWpaNetworkInfo> &networkList); 328 329 /** 330 * @Description Get current connect signal info, rssi, linkspeed, noise ... 331 * 332 * @param endBssid - peer end bssid, i.e. linked ap's bssid 333 * @param info - signal info 334 * @return WifiErrorNo 335 */ 336 WifiErrorNo GetConnectSignalInfo(const std::string &endBssid, WifiWpaSignalInfo &info); 337 338 /** 339 * @Description Get register callback objects 340 * 341 * @return const WifiEventCallback& - register sta callback objects 342 */ 343 const WifiEventCallback &GetCallbackInst(void) const; 344 345 private: 346 WifiEventCallback mStaCallback; 347 }; 348 } // namespace Wifi 349 } // namespace OHOS 350 351 #endif