• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
1 /*
2  * Copyright (C) 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 #ifndef OHOS_WIFI_HID2D_MSG_H
16 #define OHOS_WIFI_HID2D_MSG_H
17 
18 #include <string>
19 
20 #ifndef MAC_LEN
21 #define MAC_LEN 6
22 #endif
23 
24 #ifndef CFG_DATA_MAX_BYTES
25 #define CFG_DATA_MAX_BYTES 255
26 #endif
27 
28 namespace OHOS {
29 namespace Wifi {
30 enum class DhcpMode {
31     CONNECT_GO_NODHCP = 0,
32     CONNECT_AP_DHCP = 1,
33     CONNECT_AP_NODHCP = 2,
34     CONNECT_MODE_INVALID = 0xff
35 };
36 
37 enum class FreqType {
38     FREQUENCY_DEFAULT = 0,
39     FREQUENCY_160M = 1,
40 };
41 
42 enum class SelfCfgType {
43     TYPE_OF_GET_SELF_CONFIG = 1,
44     TYPE_OF_GET_SELF_CONFIG_WITH_PASSWORD = 2
45 };
46 
47 enum class PeerCfgType {
48     TYPE_OF_SET_PEER_CONFIG = 1,
49     TYPE_OF_SET_PEER_STATE_CHANGE = 2
50 };
51 
52 enum class PreferBandwidth {
53     /** default */
54     BW_DEFAULT,
55     /** indicates the ultimate bandwidth, corresponding to 160 Mbit/s or 320 Mbit/s in the future. */
56     BW_EXTRAM,
57     /** high throughput. The default value is 80 Mbit/s. */
58     BW_HIGH_PERF,
59     /** low-latency service type, 40 Mbit/s/80 Mbit/s,
60      * which needs to be determined based on the current channel status. */
61     BW_LOW_LATENCY
62 };
63 
64 enum class RecommendStatus {
65     RS_SUCCESS,
66     RS_LOCAL_ADJUST,
67     RS_REMOTE_ADJUST,
68     RS_FAILURE
69 };
70 
71 class Hid2dConnectConfig {
72 public:
Hid2dConnectConfig()73     Hid2dConnectConfig() : m_ssid(""), m_bssid(""), m_preSharedKey(""),
74         m_frequency(-1), m_dhcpMode(DhcpMode::CONNECT_MODE_INVALID) {
75     }
~Hid2dConnectConfig()76     ~Hid2dConnectConfig() {
77     }
78 
79     void SetSsid(const std::string& ssid);
80     std::string GetSsid() const;
81     void SetBssid(const std::string& bssid);
82     std::string GetBssid() const;
83     void SetPreSharedKey(const std::string& preSharedKey);
84     std::string GetPreSharedKey() const;
85     void SetFrequency(const int frequency);
86     int GetFrequency() const;
87     void SetDhcpMode(const DhcpMode dhcpMode);
88     DhcpMode GetDhcpMode() const;
89 
90 private:
91     std::string m_ssid;
92     std::string m_bssid;
93     std::string m_preSharedKey;
94     int m_frequency;
95     DhcpMode m_dhcpMode;
96 };
97 
98 class IpAddrInfo {
99 public:
100     std::string ip;
101     std::string gateway;
102     std::string netmask;
103 };
104 
105 class RecommendChannelRequest {
106 public:
RecommendChannelRequest()107     RecommendChannelRequest() : remoteIfName(""), remoteIfMode(-1), localIfName(""),
108         localIfMode(-1), prefBand(0), prefBandwidth(PreferBandwidth::BW_DEFAULT) {
109     }
110 
~RecommendChannelRequest()111     ~RecommendChannelRequest() {
112     }
113 
114     /** the interface name of the remote device */
115     std::string remoteIfName;
116     /**  the mode of the interface on the remote device */
117     int remoteIfMode;
118     /** interface name of the local device */
119     std::string localIfName;
120     /** the mode of the interface on the local device */
121     int localIfMode;
122     /** preferred frequency band */
123     int prefBand;
124     /** preferred bandwidth type (enumerated) */
125     PreferBandwidth prefBandwidth;
126 };
127 
128 class RecommendChannelResponse {
129 public:
RecommendChannelResponse()130     RecommendChannelResponse() : status(RecommendStatus::RS_FAILURE), index(-1),
131         centerFreq(0), centerFreq1(0), centerFreq2(0), bandwidth(0) {
132     }
~RecommendChannelResponse()133     ~RecommendChannelResponse() {
134     }
135 
136     /** 0: success; 1: local adjustment; 2: remote adjustment; –1: failure */
137     RecommendStatus status;
138     /* -1 fails. 0-N corresponds to the input array subscript (that is, the interface to be connected) */
139     int index;
140     /* optional 20 Mbit/s bandwidth */
141     int centerFreq;
142     /* optional frequency one */
143     int centerFreq1;
144     /* optional frequency two */
145     int centerFreq2;
146     /* band width */
147     int bandwidth;
148 };
149 }  // namespace Wifi
150 }  // namespace OHOS
151 #endif
152