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_SUPPLICANT_HAL_INTERFACE_H 17 #define OHOS_WIFI_SUPPLICANT_HAL_INTERFACE_H 18 19 #include <string> 20 #include <mutex> 21 #include "supplicant_event_callback.h" 22 #include "wifi_base_hal_interface.h" 23 #include "wifi_native_define.h" 24 #include "wifi_error_no.h" 25 #include "i_wifi_struct.h" 26 #include "define.h" 27 28 namespace OHOS { 29 namespace Wifi { 30 class WifiSupplicantHalInterface : public WifiBaseHalInterface { 31 public: 32 /** 33 * @Description Get the Instance object. 34 * 35 * @return WifiSupplicantHalInterface& 36 */ 37 static WifiSupplicantHalInterface &GetInstance(void); 38 39 /** 40 * @Description Open Supplicant. 41 * 42 * @return WifiErrorNo 43 */ 44 WifiErrorNo StartSupplicant(void) const; 45 46 /** 47 * @Description Close Supplicant. 48 * 49 * @return WifiErrorNo 50 */ 51 WifiErrorNo StopSupplicant(void) const; 52 53 /** 54 * @Description Connect Supplicant. 55 * 56 * @return WifiErrorNo 57 */ 58 WifiErrorNo ConnectSupplicant(void) const; 59 60 /** 61 * @Description Disconnect Supplicant. 62 * 63 * @return WifiErrorNo 64 */ 65 WifiErrorNo DisconnectSupplicant(void) const; 66 67 /** 68 * @Description Request to Supplicant. 69 * 70 * @param request 71 * @return WifiErrorNo 72 */ 73 WifiErrorNo RequestToSupplicant(const std::string &request) const; 74 75 /** 76 * @Description Registers the supplementary event callback function. 77 * 78 * @param callback 79 * @return WifiErrorNo 80 */ 81 WifiErrorNo RegisterSupplicantEventCallback(SupplicantEventCallback &callback); 82 83 /** 84 * @Description Deregisters the supplementary event callback function. 85 * 86 * @return WifiErrorNo 87 */ 88 WifiErrorNo UnRegisterSupplicantEventCallback(void); 89 90 /** 91 * @Description Turn on/off power save mode for the interface. 92 * 93 * @param enable 94 * @return WifiErrorNo 95 */ 96 WifiErrorNo SetPowerSave(bool enable) const; 97 98 /** 99 * @Description Setting the country code. 100 * 101 * @param countryCode 102 * @return WifiErrorNo 103 */ 104 WifiErrorNo WpaSetCountryCode(const std::string &countryCode) const; 105 106 /** 107 * @Description Obtains the country code. 108 * 109 * @param countryCode 110 * @return WifiErrorNo 111 */ 112 WifiErrorNo WpaGetCountryCode(std::string &countryCode) const; 113 114 /** 115 * @Description Get register callback objects 116 * 117 * @return const SupplicantEventCallback& - register callback objects 118 */ 119 const SupplicantEventCallback &GetCallbackInst(void) const; 120 121 /** 122 * @Description Set suspend mode to wpa 123 * 124 * @param mode - true for suspend mode, false for resume mode 125 * 126 * @Return success: WIFI_OPT_SUCCESS, fail: WIFI_OPT_FAILED 127 */ 128 WifiErrorNo WpaSetSuspendMode(bool mode) const; 129 130 /** 131 * @Description Set power mode to wpa 132 * 133 * @param mode - true for power mode, false for resume mode 134 * 135 * @Return success: WIFI_OPT_SUCCESS, fail: WIFI_OPT_FAILED 136 */ 137 WifiErrorNo WpaSetPowerMode(bool mode, int instId) const; 138 139 void NotifyScanResultEvent(); 140 private: 141 SupplicantEventCallback mCallback; 142 static std::mutex mSupplicantHalMutex; 143 }; 144 } // namespace Wifi 145 } // namespace OHOS 146 147 #endif