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 #define CFG_CALLBACK_BYTE 4 72 73 enum class CfgType { 74 CFG_INVALID = -1, 75 GET_SELF_CONFIG = 1, 76 }; 77 78 enum P2pBusinessType { 79 INVALID = -1, 80 P2P_TYPE_CLASSIC = 0, 81 P2P_TYPE_HID2D = 1, 82 }; 83 84 class Hid2dConnectConfig { 85 public: Hid2dConnectConfig()86 Hid2dConnectConfig() : m_ssid(""), m_bssid(""), m_preSharedKey(""), 87 m_frequency(-1), m_dhcpMode(DhcpMode::CONNECT_MODE_INVALID) { 88 } ~Hid2dConnectConfig()89 ~Hid2dConnectConfig() { 90 } 91 92 void SetSsid(const std::string& ssid); 93 std::string GetSsid() const; 94 void SetBssid(const std::string& bssid); 95 std::string GetBssid() const; 96 void SetPreSharedKey(const std::string& preSharedKey); 97 std::string GetPreSharedKey() const; 98 void SetFrequency(const int frequency); 99 int GetFrequency() const; 100 void SetDhcpMode(const DhcpMode dhcpMode); 101 DhcpMode GetDhcpMode() const; 102 103 private: 104 std::string m_ssid; 105 std::string m_bssid; 106 std::string m_preSharedKey; 107 int m_frequency; 108 DhcpMode m_dhcpMode; 109 }; 110 111 class IpAddrInfo { 112 public: 113 std::string ip; 114 std::string gateway; 115 std::string netmask; 116 }; 117 118 class RecommendChannelRequest { 119 public: RecommendChannelRequest()120 RecommendChannelRequest() : remoteIfName(""), remoteIfMode(-1), localIfName(""), 121 localIfMode(-1), prefBand(0), prefBandwidth(PreferBandwidth::BW_DEFAULT) { 122 } 123 ~RecommendChannelRequest()124 ~RecommendChannelRequest() { 125 } 126 127 /** the interface name of the remote device */ 128 std::string remoteIfName; 129 /** the mode of the interface on the remote device */ 130 int remoteIfMode; 131 /** interface name of the local device */ 132 std::string localIfName; 133 /** the mode of the interface on the local device */ 134 int localIfMode; 135 /** preferred frequency band */ 136 int prefBand; 137 /** preferred bandwidth type (enumerated) */ 138 PreferBandwidth prefBandwidth; 139 }; 140 141 class RecommendChannelResponse { 142 public: RecommendChannelResponse()143 RecommendChannelResponse() : status(RecommendStatus::RS_FAILURE), index(-1), 144 centerFreq(0), centerFreq1(0), centerFreq2(0), bandwidth(0) { 145 } ~RecommendChannelResponse()146 ~RecommendChannelResponse() { 147 } 148 149 /** 0: success; 1: local adjustment; 2: remote adjustment; –1: failure */ 150 RecommendStatus status; 151 /* -1 fails. 0-N corresponds to the input array subscript (that is, the interface to be connected) */ 152 int index; 153 /* optional 20 Mbit/s bandwidth */ 154 int centerFreq; 155 /* optional frequency one */ 156 int centerFreq1; 157 /* optional frequency two */ 158 int centerFreq2; 159 /* band width */ 160 int bandwidth; 161 }; 162 163 class Hid2dUpperScene { 164 public: 165 /* The mac address of the device */ 166 std::string mac; 167 /* The scene of upper layer, hexadecimal digit, currently bit 0-2 is valid, 0: video, 1: audio, 2: file */ 168 unsigned int scene; 169 /* Frame rate, -1/30/60 is valid */ 170 int fps; 171 /* band width, valid only in video scenes, the default value is 0 */ 172 unsigned int bw; 173 }; 174 } // namespace Wifi 175 } // namespace OHOS 176 #endif 177