• 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_AP_MSG_H
17 #define OHOS_WIFI_AP_MSG_H
18 #include <cstdint>
19 #include <set>
20 #include <string>
21 #include "wifi_common_msg.h"
22 
23 namespace OHOS {
24 namespace Wifi {
25 #define AP_CHANNEL_DEFAULT 6
26 #define AP_CHANNEL_5G_DEFAULT 149
27 #define WIFI_BSSID_LENGTH 18
28 enum class ApState {
29     AP_STATE_NONE = 0,
30     AP_STATE_IDLE,
31     AP_STATE_STARTING,
32     AP_STATE_STARTED,
33     AP_STATE_CLOSING,
34     AP_STATE_CLOSED,
35 };
36 
37 /* Encryption Mode */
38 enum class KeyMgmt {
39     NONE = 0,
40     WPA_PSK = 1,
41     WPA_EAP = 2,
42     IEEE8021X = 3,
43     WPA2_PSK = 4,
44     OSEN = 5,
45     FT_PSK = 6,
46     FT_EAP = 7
47 };
48 
49 enum class BandType {
50     BAND_NONE = 0, /* unknown */
51     BAND_2GHZ = 1, /* 2.4GHz */
52     BAND_5GHZ = 2, /* 5GHz */
53     BAND_ANY = 3   /* Dual-mode frequency band */
54 };
55 
56 enum class PowerModel {
57     SLEEPING = 0, /* Sleeping model. */
58     GENERAL = 1, /* General model. */
59     THROUGH_WALL = 2, /* Through wall model. */
60 };
61 
62 struct HotspotConfig {
HotspotConfigHotspotConfig63     HotspotConfig()
64     {
65         securityType = KeyMgmt::WPA2_PSK;
66         band = BandType::BAND_2GHZ;
67         channel = AP_CHANNEL_DEFAULT;
68         maxConn = -1;
69     }
70 
SetSsidHotspotConfig71     inline void SetSsid(const std::string &newSsid)
72     {
73         ssid = newSsid;
74     }
GetSsidHotspotConfig75     inline const std::string &GetSsid() const
76     {
77         return ssid;
78     }
79 
SetPreSharedKeyHotspotConfig80     inline void SetPreSharedKey(const std::string &newKey)
81     {
82         preSharedKey = newKey;
83     }
GetPreSharedKeyHotspotConfig84     inline const std::string &GetPreSharedKey() const
85     {
86         return preSharedKey;
87     }
88 
SetSecurityTypeHotspotConfig89     inline void SetSecurityType(KeyMgmt type)
90     {
91         securityType = type;
92     }
GetSecurityTypeHotspotConfig93     inline KeyMgmt GetSecurityType() const
94     {
95         return securityType;
96     }
97 
SetBandHotspotConfig98     inline void SetBand(BandType newBand)
99     {
100         band = newBand;
101     }
GetBandHotspotConfig102     inline BandType GetBand() const
103     {
104         return band;
105     }
106 
SetChannelHotspotConfig107     inline void SetChannel(int32_t newchannel)
108     {
109         channel = newchannel;
110     }
GetChannelHotspotConfig111     inline int32_t GetChannel() const
112     {
113         return channel;
114     }
115 
SetMaxConnHotspotConfig116     inline void SetMaxConn(int32_t newMaxConn)
117     {
118         maxConn = newMaxConn;
119     }
GetMaxConnHotspotConfig120     inline int32_t GetMaxConn() const
121     {
122         return maxConn;
123     }
124 
125 private:
126     std::string ssid;         /* Hotspot name, The string length range is 1~32 */
127     std::string preSharedKey; /* Hotspot password ,The string length range is 8~63 */
128     KeyMgmt securityType;     /* Hotspot Encryption type, Optional NONE/WPA_PSK/WPA2_PSK */
129     BandType band;
130     int32_t channel;
131     int32_t maxConn;
132 };
133 
134 struct StationInfo {
135     std::string deviceName; /* Device name */
136     std::string bssid;      /* Device Mac */
137     std::string ipAddr;     /* Device IP address */
138 };
139 }  // namespace Wifi
140 }  // namespace OHOS
141 #endif