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 16 #ifndef OHOS_WIFI_HID2D_H 17 #define OHOS_WIFI_HID2D_H 18 19 #include "wifi_errcode.h" 20 #include <vector> 21 #include "wifi_hid2d_msg.h" 22 23 namespace OHOS { 24 namespace Wifi { 25 class Hid2d { 26 public: 27 static std::shared_ptr<Hid2d> GetInstance(int system_ability_id); 28 29 virtual ~Hid2d(); 30 31 /** 32 * @Description Request an IP address to the Gc from the IP address pool, used on the GO side. 33 * 34 * @param gcMac - gc mac address 35 * @param ipAddr - applied ip address 36 * @return ErrCode - operation result 37 */ 38 virtual ErrCode Hid2dRequestGcIp(const std::string& gcMac, std::string& ipAddr) = 0; 39 40 /** 41 * @Description Increase(+1) hid2d shared link reference counting 42 * 43 * @return ErrCode - operation result 44 */ 45 virtual ErrCode Hid2dSharedlinkIncrease() = 0; 46 47 /** 48 * @Description Decrease(-1) hid2d shared link reference counting 49 * 50 * @return ErrCode - operation result 51 */ 52 virtual ErrCode Hid2dSharedlinkDecrease() = 0; 53 54 /** 55 * @Description Create hid2d group, used on the GO side. 56 * 57 * @param frequency - frequency 58 * @param type - frequency type 59 * @return ErrCode - operation result 60 */ 61 virtual ErrCode Hid2dCreateGroup(const int frequency, FreqType type) = 0; 62 63 /** 64 * @Description The GC side actively disconnects from the GO, used on the GC side. 65 * 66 * @param gcIfName - network interface name 67 * @return ErrCode - operation result 68 */ 69 virtual ErrCode Hid2dRemoveGcGroup(const std::string& gcIfName) = 0; 70 71 /** 72 * @Description Connect to a specified group using hid2d, used on the GC side. 73 * 74 * @param config - connection parameters 75 * @return ErrCode - operation result 76 */ 77 virtual ErrCode Hid2dConnect(const Hid2dConnectConfig& config) = 0; 78 79 /** 80 * @Description Configuring IP addresses for P2P network interfaces, used on the GC side. 81 * 82 * @param ifName - network interface name 83 * @param ipInfo - IP infos 84 * @return ErrCode - operation result 85 */ 86 virtual ErrCode Hid2dConfigIPAddr(const std::string& ifName, const IpAddrInfo& ipInfo) = 0; 87 88 /** 89 * @Description Clear IP address when the P2P connection is disconnected, used on the GC side. 90 * 91 * @param ifName - network interface name 92 * @return ErrCode - operation result 93 */ 94 virtual ErrCode Hid2dReleaseIPAddr(const std::string& ifName) = 0; 95 96 /** 97 * @Description Obtain the recommended channel and bandwidth for link setup 98 * 99 * @param request - request data 100 * @param response - response result 101 * @return ErrCode - operation result 102 */ 103 virtual ErrCode Hid2dGetRecommendChannel(const RecommendChannelRequest& request, 104 RecommendChannelResponse& response) = 0; 105 106 /** 107 * @Description get 5G channel list 108 * 109 * @param vecChannelList - result for channel list 110 * @return ErrCode - operation result 111 */ 112 virtual ErrCode Hid2dGetChannelListFor5G(std::vector<int>& vecChannelList) = 0; 113 114 /** 115 * @Description get the self wifi configuration information 116 * 117 * @param cfgType - configuration type 118 * @param cfgData - the queried data of wifi configuration 119 * @param getDatValidLen - the valid data length in the array `cfgData` 120 * @return ErrCode - operation result 121 */ 122 virtual ErrCode Hid2dGetSelfWifiCfgInfo(SelfCfgType cfgType, 123 char cfgData[CFG_DATA_MAX_BYTES], int* getDatValidLen) = 0; 124 125 /** 126 * @Description set the peer wifi configuration information 127 * 128 * @param cfgType - configuration type 129 * @param cfgData - the wifi configuration data to be set 130 * @param setDataValidLen - the valid data length in the array `cfgData` 131 * @return ErrCode - operation result 132 */ 133 virtual ErrCode Hid2dSetPeerWifiCfgInfo(PeerCfgType cfgType, 134 char cfgData[CFG_DATA_MAX_BYTES], int setDataValidLen) = 0; 135 136 /** 137 * @Description Set the scene of upper layer 138 * 139 * @param ifName - interface name 140 * @param scene - scene 141 * @return ErrCode - operate result 142 */ 143 virtual ErrCode Hid2dSetUpperScene(const std::string& ifName, const Hid2dUpperScene& scene) = 0; 144 145 /** 146 * @Description Hid2d Is Wide Bandwidth Supported 147 * 148 * @param isSupport - is support 160M 149 * @return ErrCode - operation result 150 */ 151 virtual ErrCode Hid2dIsWideBandwidthSupported(bool &isSupport) = 0; 152 }; 153 } // namespace Wifi 154 } // namespace OHOS 155 #endif