• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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, const std::string &ifaceName = "wlan0");
42 
43     /**
44      * @Description Close Ap.
45      *
46      * @return WifiErrorNo
47      */
48     virtual WifiErrorNo StopAp(int id = 0);
49 
50     /**
51      * @Description Enable SoftAP.
52      *
53      * @param id
54      * @return WifiErrorNo
55      */
56     WifiErrorNo EnableAp(int id = 0);
57 
58     /**
59      * @Description Setting SoftAP Configurations.
60      *
61      * @param config
62      * @return WifiErrorNo
63      */
64     WifiErrorNo SetSoftApConfig(const std::string &ifName, const HotspotConfig &config, int id = 0);
65 
66     /**
67      * @Description Obtains information about all connected STAs.
68      *
69      * @param result - Returns the obtained STA information list.
70      * @return WifiErrorNo
71      */
72     WifiErrorNo GetStationList(std::vector<std::string> &result, int id = 0);
73 
74     /**
75      * @Description To set the blocklist filtering in AP mode to prohibit
76      *              the MAC address connection.
77      *
78      * @param mac - Blocklisted address.
79      * @return WifiErrorNo
80      */
81     WifiErrorNo AddBlockByMac(const std::string &mac, int id = 0);
82 
83     /**
84      * @Description To set blocklist filtering in AP mode and delete a
85      *              specified MAC address from the blocklist.
86      *
87      * @param mac - Blocklisted address.
88      * @return WifiErrorNo
89      */
90     WifiErrorNo DelBlockByMac(const std::string &mac, int id = 0);
91 
92     /**
93      * @Description Disconnect the STA with a specified MAC address.
94      *
95      * @param mac - Address information.
96      * @return WifiErrorNo
97      */
98     WifiErrorNo RemoveStation(const std::string &mac, int id = 0);
99 
100     /**
101      * @Description Obtains the hotspot frequency supported by a
102      *              specified frequency band.
103      *
104      * @param band - Frequency band.
105      * @param frequencies - Frequency list.
106      * @return WifiErrorNo
107      */
108     WifiErrorNo GetFrequenciesByBand(const std::string &ifaceName, int band, std::vector<int> &frequencies);
109 
110     /**
111      * @Description Listening to Wi-Fi disconnection or connection events
112      *              of the STA in AP mode.
113      *
114      * @param callback - Structure of the callback function for AP
115      *                   registration events.
116      * @return WifiErrorNo
117      */
118     WifiErrorNo RegisterApEvent(IWifiApMonitorEventCallback callback, int id = 0);
119 
120     /**
121      * @Description Sets the Wi-Fi country code.
122      *
123      * @param code
124      * @return WifiErrorNo
125      */
126     WifiErrorNo SetWifiCountryCode(const std::string &ifaceName, const std::string &code);
127 
128     /**
129      * @Description Disconnect STAs based on MAC addresses.
130      *
131      * @param mac
132      * @return WifiErrorNo
133      */
134     WifiErrorNo DisconnectStaByMac(const std::string &mac, int id = 0);
135 
136     /**
137      * @Description Get the Ap Callback Inst object
138      *
139      * @return const IWifiApMonitorEventCallback& - register ap callback objects
140      */
141     const IWifiApMonitorEventCallback &GetApCallbackInst(int id = 0) const;
142 
143     /**
144      * @Description Get power mode.
145      *
146      * @param model
147      * @return WifiErrorNo
148      */
149     WifiErrorNo GetPowerModel(const std::string &ifaceName, int& model);
150 
151     /**
152      * @Description Set power mode.
153      *
154      * @param model
155      * @return WifiErrorNo
156      */
157     WifiErrorNo SetPowerModel(const std::string &ifaceName, int model);
158 
159     /**
160      * @Description Set the MAC address of the ap.
161      *
162      * @param mac
163      * @return WifiErrorNo
164      */
165     WifiErrorNo SetConnectMacAddr(const std::string &ifaceName, const std::string &mac);
166 private:
167     std::map<int, IWifiApMonitorEventCallback> mApCallback;
168 };
169 }  // namespace Wifi
170 }  // namespace OHOS
171 
172 #endif