• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 Check whether Wi-Fi hotspot is can be operated under some situation. For example, When the airplane
52      * mode is turned on and does not support the coexistence of softap and sta, nor does it support signal bridge,
53      * the hotspot switch cannot be operated.
54      *
55      * @param isSupported - Supported / NOT Supported
56      * @return ErrCode - operation result
57      */
58     virtual ErrCode IsOpenSoftApAllowed(bool &isSupported) = 0;
59 
60     /**
61      * @Description Get the Hotspot Config object
62      *
63      * @param state - Result of obtaining the hotspot status
64      * @return ErrCode - operation result
65      */
66     virtual ErrCode GetHotspotState(int &state) = 0;
67 
68     /**
69      * @Description Get the Hotspot State object
70      *
71      * @param config - Current hotspot configuration
72      * @return ErrCode - operation result
73      */
74     virtual ErrCode GetHotspotConfig(HotspotConfig &config) = 0;
75 
76     /**
77      * @Description Set the configuration of Hotspot
78      *
79      * @param config - HotspotConfig object,
80      * @return ErrCode - operation result
81      */
82     virtual ErrCode SetHotspotConfig(const HotspotConfig &config) = 0;
83 
84     /**
85      * @Description Set the idel timeout of Hotspot
86      *
87      * @param time -input time,
88      * @return ErrCode - operation result
89      */
90     virtual ErrCode SetHotspotIdleTimeout(int time) = 0;
91 
92     /**
93      * @Description Get the Station List object
94      *
95      * @param result - Get result vector of connect Station Info
96      * @return ErrCode - operation result
97      */
98     virtual ErrCode GetStationList(std::vector<StationInfo> &result) = 0;
99 
100     /**
101      * @Description Disconnects a specified sta connection when ap is opened
102      *
103      * @param info - StationInfo object
104      * @return ErrCode - operation result
105      */
106     virtual ErrCode DisassociateSta(const StationInfo &info) = 0;
107 
108     /**
109      * @Description Enable Hotspot
110      *
111      * @param type - service type
112      * @return ErrCode - operation result
113      */
114     virtual ErrCode EnableHotspot(const ServiceType type = ServiceType::DEFAULT) = 0;
115 
116     /**
117      * @Description Disable Hotspot
118      *
119      * @param type - service type
120      * @return ErrCode - operation result
121      */
122     virtual ErrCode DisableHotspot(const ServiceType type = ServiceType::DEFAULT) = 0;
123 
124     /**
125      * @Description Get the Block Lists object
126      *
127      * @param infos - Get Blocklist result vector of StationInfo
128      * @return ErrCode - operation result
129      */
130     virtual ErrCode GetBlockLists(std::vector<StationInfo> &infos) = 0;
131 
132     /**
133      * @Description Add a StationInfo object to Blocklist when ap is opened
134      *
135      * @param info - StationInfo object
136      * @return ErrCode - operation result
137      */
138     virtual ErrCode AddBlockList(const StationInfo &info) = 0;
139 
140     /**
141      * @Description Del a StationInfo object from Blocklist
142      *
143      * @param info - StationInfo object
144      * @return ErrCode - operation result
145      */
146     virtual ErrCode DelBlockList(const StationInfo &info) = 0;
147 
148     /**
149      * @Description Get the Valid Bands object
150      *
151      * @param bands - Get result vector of BandType when ap is opened
152      * @return ErrCode - operation result
153      */
154     virtual ErrCode GetValidBands(std::vector<BandType> &bands) = 0;
155 
156     /**
157      * @Description Get the Valid Channels object when ap is opened
158      *
159      * @param band - Specified Valid Band.
160      * @param validchannels - Obtains the channels corresponding to the specified band
161      * @return ErrCode - operation result
162      */
163     virtual ErrCode GetValidChannels(BandType band, std::vector<int32_t> &validchannels) = 0;
164 
165     /**
166      * @Description Register callback client
167      *
168      * @param callback - callback struct
169      * @return ErrCode - operation result
170      */
171     virtual ErrCode RegisterCallBack(const sptr<IWifiHotspotCallback> &callback,
172         const std::vector<std::string> &event) = 0;
173 
174     /**
175      * @Description Get supported features
176      *
177      * @param features - return supported features
178      * @return ErrCode - operation result
179      */
180     virtual ErrCode GetSupportedFeatures(long &features) = 0;
181 
182     /**
183      * @Description Check if supported input feature
184      *
185      * @param feature - input feature
186      * @return bool - true if supported, false if unsupported
187      */
188     virtual bool IsFeatureSupported(long feature) = 0;
189 
190     /**
191      * @Description Get supported power model list
192      *
193      * @param setPowerModelList - supported power model list
194      * @return ErrCode - operation result
195      */
196     virtual ErrCode GetSupportedPowerModel(std::set<PowerModel>& setPowerModelList) = 0;
197 
198     /**
199      * @Description Get power model
200      *
201      * @param model - current power model
202      * @return ErrCode - operation result
203      */
204     virtual ErrCode GetPowerModel(PowerModel& model) = 0;
205 
206     /**
207      * @Description Get supported power model list
208      *
209      * @param model - the model to be set
210      * @return ErrCode - operation result
211      */
212     virtual ErrCode SetPowerModel(const PowerModel& model) = 0;
213 
214     /**
215      * @Description Get ap iface name
216      *
217      * @param ifaceName - the ifaceName to be set
218      * @return ErrCode - operation result
219      */
220     virtual ErrCode GetApIfaceName(std::string& ifaceName) = 0;
221 
222     /**
223      * @Description Enable local only Hotspot
224      *
225      * @param type - service type
226      * @return ErrCode - operation result
227      */
228     virtual ErrCode EnableLocalOnlyHotspot(const ServiceType type = ServiceType::DEFAULT) = 0;
229 
230     /**
231      * @Description Disable local only Hotspot
232      *
233      * @param type - service type
234      * @return ErrCode - operation result
235      */
236     virtual ErrCode DisableLocalOnlyHotspot(const ServiceType type = ServiceType::DEFAULT) = 0;
237 
238     /**
239      * @Description Get local only Hotspot mode
240      *
241      * @param mode - hotspot mode
242      * @return ErrCode - operation result
243      */
244     virtual ErrCode GetHotspotMode(HotspotMode &mode) = 0;
245 
246     /**
247      * @Description Get the LocalOnly Hotspot State object
248      *
249      * @param config - Current LocalOnly hotspot configuration
250      * @return ErrCode - operation result
251      */
252     virtual ErrCode GetLocalOnlyHotspotConfig(HotspotConfig &config) = 0;
253 };
254 }  // namespace Wifi
255 }  // namespace OHOS
256 #endif