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_AP_HAL_INTERFACE_H 17 #define OHOS_WIFI_AP_HAL_INTERFACE_H 18 19 #include <string> 20 #include <vector> 21 #include "wifi_msg.h" 22 #include "i_wifi_hotspot_iface.h" 23 #include "wifi_base_hal_interface.h" 24 25 namespace OHOS { 26 namespace Wifi { 27 class WifiApHalInterface : public WifiBaseHalInterface { 28 public: 29 /** 30 * @Description Get the Instance object. 31 * 32 * @return WifiApHalInterface& 33 */ 34 static WifiApHalInterface &GetInstance(void); 35 36 /** 37 * @Description Start Ap. 38 * 39 * @return WifiErrorNo 40 */ 41 virtual WifiErrorNo StartAp(int id = 0); 42 43 /** 44 * @Description Close Ap. 45 * 46 * @return WifiErrorNo 47 */ 48 virtual WifiErrorNo StopAp(int id = 0); 49 50 /** 51 * @Description Setting SoftAP Configurations. 52 * 53 * @param config 54 * @return WifiErrorNo 55 */ 56 WifiErrorNo SetSoftApConfig(const HotspotConfig &config, int id = 0); 57 58 /** 59 * @Description Obtains information about all connected STAs. 60 * 61 * @param result - Returns the obtained STA information list. 62 * @return WifiErrorNo 63 */ 64 WifiErrorNo GetStationList(std::vector<std::string> &result, int id = 0); 65 66 /** 67 * @Description To set the blocklist filtering in AP mode to prohibit 68 * the MAC address connection. 69 * 70 * @param mac - Blocklisted address. 71 * @return WifiErrorNo 72 */ 73 WifiErrorNo AddBlockByMac(const std::string &mac, int id = 0); 74 75 /** 76 * @Description To set blocklist filtering in AP mode and delete a 77 * specified MAC address from the blocklist. 78 * 79 * @param mac - Blocklisted address. 80 * @return WifiErrorNo 81 */ 82 WifiErrorNo DelBlockByMac(const std::string &mac, int id = 0); 83 84 /** 85 * @Description Disconnect the STA with a specified MAC address. 86 * 87 * @param mac - Address information. 88 * @return WifiErrorNo 89 */ 90 WifiErrorNo RemoveStation(const std::string &mac, int id = 0); 91 92 /** 93 * @Description Obtains the hotspot frequency supported by a 94 * specified frequency band. 95 * 96 * @param band - Frequency band. 97 * @param frequencies - Frequency list. 98 * @return WifiErrorNo 99 */ 100 WifiErrorNo GetFrequenciesByBand(int band, std::vector<int> &frequencies, int id = 0); 101 102 /** 103 * @Description Listening to Wi-Fi disconnection or connection events 104 * of the STA in AP mode. 105 * 106 * @param callback - Structure of the callback function for AP 107 * registration events. 108 * @return WifiErrorNo 109 */ 110 WifiErrorNo RegisterApEvent(IWifiApMonitorEventCallback callback, int id = 0); 111 112 /** 113 * @Description Sets the Wi-Fi country code. 114 * 115 * @param code 116 * @return WifiErrorNo 117 */ 118 WifiErrorNo SetWifiCountryCode(const std::string &code, int id = 0); 119 120 /** 121 * @Description Disconnect STAs based on MAC addresses. 122 * 123 * @param mac 124 * @return WifiErrorNo 125 */ 126 WifiErrorNo DisconnectStaByMac(const std::string &mac, int id = 0); 127 128 /** 129 * @Description Get the Ap Callback Inst object 130 * 131 * @return const IWifiApMonitorEventCallback& - register ap callback objects 132 */ 133 const IWifiApMonitorEventCallback &GetApCallbackInst(int id = 0) const; 134 135 /** 136 * @Description Get power mode. 137 * 138 * @param model 139 * @return WifiErrorNo 140 */ 141 WifiErrorNo GetPowerModel(int& model, int id = 0) const; 142 143 /** 144 * @Description Set power mode. 145 * 146 * @param model 147 * @return WifiErrorNo 148 */ 149 WifiErrorNo SetPowerModel(const int& model, int id = 0) const; 150 151 private: 152 std::map<int, IWifiApMonitorEventCallback> mApCallback; 153 }; 154 } // namespace Wifi 155 } // namespace OHOS 156 157 #endif