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