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_config.h
30  *
31  * @brief Defines the Wi-Fi hotspot configuration.
32  *
33  * @since 7
34  */
35 
36 #ifndef WIFI_HOTSPOT_CONFIG_C_H
37 #define WIFI_HOTSPOT_CONFIG_C_H
38 
39 #include "wifi_device_config.h"
40 #include "wifi_error_code.h"
41 
42 /**
43  * @brief Defines the maximum number of stations connected to a hotspot.
44  */
45 #define WIFI_MAX_STA_NUM 6
46 
47 /**
48  * @brief Enumerates received signal strength indicator (RSSI) levels.
49  *
50  * Four RSSI levels are available: 1 to 4. The higher the RSSI level, the stronger the Wi-Fi signal.
51  *
52  * @since 7
53  */
54 typedef enum {
55     /** Level 1. The RSSI value for a 2.4 GHz hotspot ranges from <b>-88</b> (included) to <b>-82</b> (excluded),
56      * and that for a 5 GHz hotspot ranges from <b>-85</b> (included) to <b>-79</b> (excluded). */
57     RSSI_LEVEL_1 = 1,
58     /** Level 2. The RSSI value for a 2.4 GHz hotspot ranges from <b>-82</b> (included) to <b>-75</b> (excluded),
59      * and that for a 5 GHz hotspot ranges from <b>-79</b> (included) to <b>-72</b> (excluded). */
60     RSSI_LEVEL_2 = 2,
61     /** Level 3. The RSSI value for a 2.4 GHz hotspot ranges from <b>-75</b> (included) to <b>-65</b> (excluded),
62      * and that for a 5 GHz hotspot ranges from <b>-72</b> (included) to <b>-65</b> (excluded). */
63     RSSI_LEVEL_3 = 3,
64     /** Level 4. The RSSI value for a 2.4 GHz or 5 GHz hotspot is greater than or equal to <b>-65</b>. */
65     RSSI_LEVEL_4 = 4,
66 } RssiLevel;
67 
68 /**
69  * @brief Enumerates frequency bands supported by the Wi-Fi hotspot mode.
70  *
71  * @since 7
72  */
73 typedef enum {
74     /** 2.4 GHz */
75     HOTSPOT_BAND_TYPE_2G = 1,
76     /** 5 GHz */
77     HOTSPOT_BAND_TYPE_5G = 2,
78 } HotspotBandType;
79 
80 /**
81  * @brief Represents the hotspot configuration.
82  *
83  * A hotspot configuration must contain the SSID (or BSSID), security type, and key (if the security type is open). \n
84  *
85  * @since 7
86  */
87 typedef struct {
88     /** Service set ID (SSID). For its length, see {@link WIFI_MAX_SSID_LEN}. */
89     char ssid[WIFI_MAX_SSID_LEN];
90     /** Security type */
91     int securityType;
92     /** Frequency band */
93     int band;
94     /** Channel number */
95     int channelNum;
96     /** Key. For its length, see {@link WIFI_MAX_SSID_LEN}. */
97     char preSharedKey[WIFI_MAX_KEY_LEN];
98 } HotspotConfig;
99 
100 /**
101  * @brief Sets the frequency band for this hotspot.
102  *
103  * @param band Indicates the frequency band to set.
104  * @return Returns {@link WIFI_SUCCESS} if the frequency band is set; returns an error code defined in
105  * {@link WifiErrorCode} otherwise.
106  * @since 7
107  */
108 WifiErrorCode SetBand(int band);
109 
110 /**
111  * @brief Obtains the frequency band of this hotspot.
112  *
113  * @param result Indicates the obtained frequency band.
114  * @return Returns {@link WIFI_SUCCESS} if the frequency band is obtained; returns an error code defined in
115  * {@link WifiErrorCode} otherwise.
116  * @since 7
117  */
118 WifiErrorCode GetBand(int *result);
119 
120 #endif // WIFI_HOTSPOT_CONFIG_C_H
121 /** @} */
122