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 16 #ifndef OHOS_WIFI_HOTSPOT_H 17 #define OHOS_WIFI_HOTSPOT_H 18 19 #include <memory> 20 #include <string> 21 #include <vector> 22 #include "wifi_errcode.h" 23 #include "wifi_ap_msg.h" 24 #include "i_wifi_hotspot_callback.h" 25 26 namespace OHOS { 27 namespace Wifi { 28 class WifiHotspot { 29 public: 30 static std::shared_ptr<WifiHotspot> GetInstance(int system_ability_id, int id = 0); 31 32 virtual ~WifiHotspot(); 33 34 /** 35 * @Description Check whether the hotspot is active. 36 * 37 * @param isActive - active / inactive 38 * @return ErrCode - operation result 39 */ 40 virtual ErrCode IsHotspotActive(bool &isActive) = 0; 41 42 /** 43 * @Description Check whether the hotspot supports dual band. 44 * 45 * @param isSupported - Supported / NOT Supported 46 * @return ErrCode - operation result 47 */ 48 virtual ErrCode IsHotspotDualBandSupported(bool &isSupported) = 0; 49 50 /** 51 * @Description Get the Hotspot Config object 52 * 53 * @param state - Result of obtaining the hotspot status 54 * @return ErrCode - operation result 55 */ 56 virtual ErrCode GetHotspotState(int &state) = 0; 57 58 /** 59 * @Description Get the Hotspot State object 60 * 61 * @param config - Current hotspot configuration 62 * @return ErrCode - operation result 63 */ 64 virtual ErrCode GetHotspotConfig(HotspotConfig &config) = 0; 65 66 /** 67 * @Description Set the configuration of Hotspot 68 * 69 * @param config - HotspotConfig object, 70 * @return ErrCode - operation result 71 */ 72 virtual ErrCode SetHotspotConfig(const HotspotConfig &config) = 0; 73 74 /** 75 * @Description Set the idel timeout of Hotspot 76 * 77 * @param time -input time, 78 * @return ErrCode - operation result 79 */ 80 virtual ErrCode SetHotspotIdleTimeout(int time) = 0; 81 82 /** 83 * @Description Get the Station List object 84 * 85 * @param result - Get result vector of connect Station Info 86 * @return ErrCode - operation result 87 */ 88 virtual ErrCode GetStationList(std::vector<StationInfo> &result) = 0; 89 90 /** 91 * @Description Disconnects a specified sta connection when ap is opened 92 * 93 * @param info - StationInfo object 94 * @return ErrCode - operation result 95 */ 96 virtual ErrCode DisassociateSta(const StationInfo &info) = 0; 97 98 /** 99 * @Description Enable Hotspot 100 * 101 * @param type - service type 102 * @return ErrCode - operation result 103 */ 104 virtual ErrCode EnableHotspot(const ServiceType type = ServiceType::DEFAULT) = 0; 105 106 /** 107 * @Description Disable Hotspot 108 * 109 * @param type - service type 110 * @return ErrCode - operation result 111 */ 112 virtual ErrCode DisableHotspot(const ServiceType type = ServiceType::DEFAULT) = 0; 113 114 /** 115 * @Description Get the Block Lists object 116 * 117 * @param infos - Get Blocklist result vector of StationInfo 118 * @return ErrCode - operation result 119 */ 120 virtual ErrCode GetBlockLists(std::vector<StationInfo> &infos) = 0; 121 122 /** 123 * @Description Add a StationInfo object to Blocklist when ap is opened 124 * 125 * @param info - StationInfo object 126 * @return ErrCode - operation result 127 */ 128 virtual ErrCode AddBlockList(const StationInfo &info) = 0; 129 130 /** 131 * @Description Del a StationInfo object from Blocklist 132 * 133 * @param info - StationInfo object 134 * @return ErrCode - operation result 135 */ 136 virtual ErrCode DelBlockList(const StationInfo &info) = 0; 137 138 /** 139 * @Description Get the Valid Bands object 140 * 141 * @param bands - Get result vector of BandType when ap is opened 142 * @return ErrCode - operation result 143 */ 144 virtual ErrCode GetValidBands(std::vector<BandType> &bands) = 0; 145 146 /** 147 * @Description Get the Valid Channels object when ap is opened 148 * 149 * @param band - Specified Valid Band. 150 * @param validchannels - Obtains the channels corresponding to the specified band 151 * @return ErrCode - operation result 152 */ 153 virtual ErrCode GetValidChannels(BandType band, std::vector<int32_t> &validchannels) = 0; 154 155 /** 156 * @Description Register callback client 157 * 158 * @param callback - callback struct 159 * @return ErrCode - operation result 160 */ 161 virtual ErrCode RegisterCallBack(const sptr<IWifiHotspotCallback> &callback, 162 const std::vector<std::string> &event) = 0; 163 164 /** 165 * @Description Get supported features 166 * 167 * @param features - return supported features 168 * @return ErrCode - operation result 169 */ 170 virtual ErrCode GetSupportedFeatures(long &features) = 0; 171 172 /** 173 * @Description Check if supported input feature 174 * 175 * @param feature - input feature 176 * @return bool - true if supported, false if unsupported 177 */ 178 virtual bool IsFeatureSupported(long feature) = 0; 179 180 /** 181 * @Description Get supported power model list 182 * 183 * @param setPowerModelList - supported power model list 184 * @return ErrCode - operation result 185 */ 186 virtual ErrCode GetSupportedPowerModel(std::set<PowerModel>& setPowerModelList) = 0; 187 188 /** 189 * @Description Get power model 190 * 191 * @param model - current power model 192 * @return ErrCode - operation result 193 */ 194 virtual ErrCode GetPowerModel(PowerModel& model) = 0; 195 196 /** 197 * @Description Get supported power model list 198 * 199 * @param model - the model to be set 200 * @return ErrCode - operation result 201 */ 202 virtual ErrCode SetPowerModel(const PowerModel& model) = 0; 203 204 /** 205 * @Description Get ap iface name 206 * 207 * @param ifaceName - the ifaceName to be set 208 * @return ErrCode - operation result 209 */ 210 virtual ErrCode GetApIfaceName(std::string& ifaceName) = 0; 211 }; 212 } // namespace Wifi 213 } // namespace OHOS 214 #endif