• 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 "wifi_base_hal_interface.h"
23 #include "wifi_ap_event_callback.h"
24 #include "wifi_error_no.h"
25 #include "wifi_ap_msg.h"
26 
27 namespace OHOS {
28 namespace Wifi {
29 class WifiApHalInterface : public WifiBaseHalInterface {
30 public:
31     /**
32      * @Description Get the Instance object.
33      *
34      * @return WifiApHalInterface&
35      */
36     static WifiApHalInterface &GetInstance(void);
37 
38     /**
39      * @Description Start Ap.
40      *
41      * @return WifiErrorNo
42      */
43     virtual WifiErrorNo StartAp(int id = 0, const std::string &ifaceName = "wlan0");
44 
45     /**
46      * @Description Close Ap.
47      *
48      * @return WifiErrorNo
49      */
50     virtual WifiErrorNo StopAp(int id = 0);
51 
52     /**
53      * @Description Enable SoftAP.
54      *
55      * @param id
56      * @return WifiErrorNo
57      */
58     WifiErrorNo EnableAp(int id = 0);
59 
60     /**
61      * @Description SetApPasswd SoftAP.
62      *
63      * @param pass
64      * @return WifiErrorNo
65      */
66     WifiErrorNo SetApPasswd(const char *pass, int id = 0);
67 
68     /**
69      * @Description Setting SoftAP Configurations.
70      *
71      * @param config
72      * @return WifiErrorNo
73      */
74     WifiErrorNo SetSoftApConfig(const std::string &ifName, const HotspotConfig &config, int id = 0);
75 
76     /**
77      * @Description Set Max ConnectNum.
78      *
79      * @param ifName ifaceName
80      * @param channel chanel of apconfig
81      * @param maxConn max Connect num
82      * @return WifiErrorNo
83      */
84     WifiErrorNo SetMaxConnectNum(const std::string &ifName, int32_t channel, int32_t maxConn);
85 
86     /**
87      * @Description Obtains information about all connected STAs.
88      *
89      * @param result - Returns the obtained STA information list.
90      * @return WifiErrorNo
91      */
92     WifiErrorNo GetStationList(std::vector<std::string> &result, int id = 0);
93 
94     /**
95      * @Description set block list of ap
96      * @param ifaceName ifaceName
97      * @param blockList mac address of block devices
98      * @return WifiErrorNo
99      */
100     WifiErrorNo SetSoftApBlockList(const std::string &ifaceName, const std::vector<std::string> &blockList);
101 
102     /**
103      * @Description disassociate with target device
104      * @param ifaceName ifaceName
105      * @param mac mac address of target device
106      * @return WifiErrorNo
107      */
108     WifiErrorNo DisAssociateSta(const std::string &ifaceName, const std::string &mac);
109 
110     /**
111      * @Description To set the blocklist filtering in AP mode to prohibit
112      *              the MAC address connection.
113      *
114      * @param mac - Blocklisted address.
115      * @return WifiErrorNo
116      */
117     WifiErrorNo AddBlockByMac(const std::string &mac, int id = 0);
118 
119     /**
120      * @Description To set blocklist filtering in AP mode and delete a
121      *              specified MAC address from the blocklist.
122      *
123      * @param mac - Blocklisted address.
124      * @return WifiErrorNo
125      */
126     WifiErrorNo DelBlockByMac(const std::string &mac, int id = 0);
127 
128     /**
129      * @Description Disconnect the STA with a specified MAC address.
130      *
131      * @param mac - Address information.
132      * @return WifiErrorNo
133      */
134     WifiErrorNo RemoveStation(const std::string &mac, int id = 0);
135 
136     /**
137      * @Description Obtains the hotspot frequency supported by a
138      *              specified frequency band.
139      *
140      * @param band - Frequency band.
141      * @param frequencies - Frequency list.
142      * @return WifiErrorNo
143      */
144     WifiErrorNo GetFrequenciesByBand(const std::string &ifaceName, int band, std::vector<int> &frequencies);
145 
146     /**
147      * @Description Listening to Wi-Fi disconnection or connection events
148      *              of the STA in AP mode.
149      *
150      * @param callback - Structure of the callback function for AP
151      *                   registration events.
152      * @return WifiErrorNo
153      */
154     WifiErrorNo RegisterApEvent(IWifiApMonitorEventCallback callback, int id = 0);
155 
156     /**
157      * @Description Sets the Wi-Fi country code.
158      *
159      * @param code
160      * @return WifiErrorNo
161      */
162     WifiErrorNo SetWifiCountryCode(const std::string &ifaceName, const std::string &code);
163 
164     /**
165      * @Description Disconnect STAs based on MAC addresses.
166      *
167      * @param mac
168      * @return WifiErrorNo
169      */
170     WifiErrorNo DisconnectStaByMac(const std::string &mac, int id = 0);
171 
172     /**
173      * @Description Get the Ap Callback Inst object
174      *
175      * @return const IWifiApMonitorEventCallback& - register ap callback objects
176      */
177     const IWifiApMonitorEventCallback &GetApCallbackInst(int id = 0) const;
178 
179     /**
180      * @Description Get power mode.
181      *
182      * @param model
183      * @return WifiErrorNo
184      */
185     WifiErrorNo GetPowerModel(const std::string &ifaceName, int& model);
186 
187     /**
188      * @Description Set power mode.
189      *
190      * @param model
191      * @return WifiErrorNo
192      */
193     WifiErrorNo SetPowerModel(const std::string &ifaceName, int model);
194 
195     /**
196      * @Description Set the MAC address of the ap.
197      *
198      * @param mac
199      * @return WifiErrorNo
200      */
201     WifiErrorNo SetConnectMacAddr(const std::string &ifaceName, const std::string &mac);
202 private:
203     std::map<int, IWifiApMonitorEventCallback> mApCallback;
204 };
205 }  // namespace Wifi
206 }  // namespace OHOS
207 
208 #endif