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