1 /*
2  * Copyright (c) 2020 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 /**
17  * @addtogroup wifiservice
18  * @{
19  *
20  * @brief Provides functions for the Wi-Fi station and hotspot modes.
21  *
22  * You can use this module to enable and disable the Wi-Fi station or hotspot mode, connect to and disconnect from a
23  * station or hotspot, query the station or hotspot status, and listen for events. \n
24  *
25  * @since 7
26  */
27 
28 /**
29  * @file wifi_hotspot.h
30  *
31  * @brief Provides capabilities to enable and disable the hotspot mode, connect to and disconnect from a hotspot, query
32  * the hotspot status, and listen for events.
33  *
34  * @since 7
35  */
36 
37 #ifndef WIFI_LITE_WIFI_HOTSPOT_H
38 #define WIFI_LITE_WIFI_HOTSPOT_H
39 #include "wifi_device.h"
40 #include "wifi_error_code.h"
41 #include "wifi_hotspot_config.h"
42 #include "wifi_event.h"
43 
44 #ifdef __cplusplus
45 extern "C" {
46 #endif
47 
48 /**
49  * @brief Defines the default channel of the hotspot mode.
50  */
51 #define HOTSPOT_DEFAULT_CHANNEL 6
52 
53 /**
54  * @brief Enables the hotspot mode.
55  *
56  * Before using this function, you need to invoke {@link SetHotspotConfig} and set at least the SSID, security type,
57  * and key. \n
58  *
59  * @return Returns {@link WIFI_SUCCESS} if the hotspot mode is enabled; returns an error code defined in
60  * {@link WifiErrorCode} otherwise.
61  * @since 7
62  */
63 WifiErrorCode EnableHotspot(void);
64 
65 /**
66  * @brief Disables the hotspot mode.
67  *
68  * @return Returns {@link WIFI_SUCCESS} if the hotspot mode is disabled; returns an error code defined in
69  * {@link WifiErrorCode} otherwise.
70  * @since 7
71  */
72 WifiErrorCode DisableHotspot(void);
73 
74 /**
75  * @brief Sets a specified hotspot configuration.
76  *
77  * The hotspot configuration includes the SSID, security type, and key. The configuration set overwrites the existing
78  * configuration and takes effect after the hotspot mode is re-enabled. \n
79  * Before enabling the hotspot mode for the first time, you must call this function. \n
80  *
81  * @param config Indicates the hotspot configuration to set.
82  * @return Returns {@link WIFI_SUCCESS} if the hotspot configuration is set; returns an error code defined in
83  * {@link WifiErrorCode} otherwise.
84  * @since 7
85  */
86 WifiErrorCode SetHotspotConfig(const HotspotConfig *config);
87 
88 /**
89  * @brief Obtains a specified hotspot configuration.
90  *
91  * The hotspot configuration includes the SSID, security type, and key. \n
92  *
93  * @param result Indicates the obtained hotspot configuration.
94  * @return Returns {@link WIFI_SUCCESS} if the hotspot configuration is obtained; returns an error code defined in
95  * {@link WifiErrorCode} otherwise.
96  * @since 7
97  */
98 WifiErrorCode GetHotspotConfig(HotspotConfig *result);
99 
100 /**
101  * @brief Checks whether the hotspot mode is enabled.
102  *
103  * @return Returns {@link WIFI_HOTSPOT_ACTIVE} if the hotspot mode is enabled; returns {@link WIFI_HOTSPOT_NOT_ACTIVE}
104  * otherwise.
105  * @since 7
106  */
107 int IsHotspotActive(void);
108 
109 /**
110  * @brief Obtains an array of stations connected to this hotspot.
111  *
112  * The station information is defined in {@link StationInfo}. \n
113  *
114  * @param result Indicates the array of stations connected to this hotspot. The array is requested and released by the
115  * caller. The value must be greater than or equal to {@link WIFI_MAX_STA_NUM}.
116  * @param size Indicates the size of the array.
117  * @return Returns {@link WIFI_SUCCESS} if the array of stations connected to this hotspot is obtained; returns an error
118  *  code defined in {@link WifiErrorCode} otherwise.
119  * @since 7
120  */
121 WifiErrorCode GetStationList(StationInfo *result, unsigned int *size);
122 
123 /**
124  * @brief Disconnects from the station with a specified MAC address.
125  *
126  * @param mac Indicates the pointer to the MAC address of the station.
127  * @param macLen Indicates the length of the MAC address of the station.
128  * @return Returns {@link WIFI_SUCCESS} if the function is successfully called;
129  * returns an error code defined in {@link WifiErrorCode} otherwise.
130  * @since 7
131  */
132 WifiErrorCode DisassociateSta(unsigned char *mac, int macLen);
133 
134 /**
135  * @brief Adds the hotspot transmit power to the beacon.
136  *
137  * After the transmit power is added, the beacon must contain specified IEs. If the minimum transmit power
138  * <b>0xFFFFFFFF</b> is added, the beacon does not contain the IEs. \n
139  * The transmit power is added to the <b>ie</b> field only, exerting no impacts on the transmit power. \n
140  * @param power Indicates the transmit power to add.
141  * @return Returns {@link WIFI_SUCCESS} if the function is successfully called; returns an error code defined
142  * in {@link WifiErrorCode} otherwise.
143  * @since 7
144  */
145 WifiErrorCode AddTxPowerInfo(int power);
146 
147 /**
148  * @brief Get ap iface name.
149  *
150  * @param iface name
151  * @param iface name array size.
152  * @return Returns {@link WIFI_SUCCESS} if Get ap iface name success; returns an error.
153  * code defined in {@link WifiErrorCode} otherwise.
154  * @since 7
155  */
156 WifiErrorCode GetApIfaceName(char *ifaceName, int nameLen);
157 #ifdef __cplusplus
158 }
159 #endif
160 
161 #endif // WIFI_LITE_WIFI_HOTSPOT_H_
162 /** @} */
163