1 /*
2 * Copyright (c) 2024 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 #include "wifi_ext_iface.h"
17 #include <hdf_log.h>
18
19 namespace OHOS {
20 namespace HDI {
21 namespace Wlan {
22 namespace Chip {
23 namespace V1_0 {
WifiExtIface(const std::string & ifName,const std::weak_ptr<WifiVendorHal> vendorHal,const std::weak_ptr<IfaceUtil> ifaceUtil)24 WifiExtIface::WifiExtIface(
25 const std::string& ifName,
26 const std::weak_ptr<WifiVendorHal> vendorHal,
27 const std::weak_ptr<IfaceUtil> ifaceUtil)
28 : ifName_(ifName),
29 vendorHal_(vendorHal),
30 ifaceUtil_(ifaceUtil),
31 isValid_(true) {}
32
Invalidate()33 void WifiExtIface::Invalidate()
34 {
35 vendorHal_.reset();
36 isValid_ = false;
37 }
38
IsValid()39 bool WifiExtIface::IsValid()
40 {
41 return isValid_;
42 }
43
GetName()44 std::string WifiExtIface::GetName()
45 {
46 return ifName_;
47 }
48
GetIfaceType(IfaceType & type)49 int32_t WifiExtIface::GetIfaceType(IfaceType& type)
50 {
51 return HDF_ERR_NOT_SUPPORT;
52 }
53
GetIfaceName(std::string & name)54 int32_t WifiExtIface::GetIfaceName(std::string& name)
55 {
56 return HDF_ERR_NOT_SUPPORT;
57 }
58
GetSupportFreqs(int band,std::vector<uint32_t> & frequencies)59 int32_t WifiExtIface::GetSupportFreqs(int band, std::vector<uint32_t>& frequencies)
60 {
61 return HDF_ERR_NOT_SUPPORT;
62 }
63
GetIfaceCap(uint32_t & capabilities)64 int32_t WifiExtIface::GetIfaceCap(uint32_t& capabilities)
65 {
66 return HDF_ERR_NOT_SUPPORT;
67 }
68
SetMacAddress(const std::string & mac)69 int32_t WifiExtIface::SetMacAddress(const std::string& mac)
70 {
71 return HDF_ERR_NOT_SUPPORT;
72 }
73
SetCountryCode(const std::string & code)74 int32_t WifiExtIface::SetCountryCode(const std::string& code)
75 {
76 return HDF_ERR_NOT_SUPPORT;
77 }
78
GetPowerMode(int32_t & powerMode)79 int32_t WifiExtIface::GetPowerMode(int32_t& powerMode)
80 {
81 return HDF_ERR_NOT_SUPPORT;
82 }
83
SetPowerMode(int32_t powerMode)84 int32_t WifiExtIface::SetPowerMode(int32_t powerMode)
85 {
86 return HDF_ERR_NOT_SUPPORT;
87 }
88
RegisterChipIfaceCallBack(const sptr<IChipIfaceCallback> & chipIfaceCallback)89 int32_t WifiExtIface::RegisterChipIfaceCallBack(const sptr<IChipIfaceCallback>& chipIfaceCallback)
90 {
91 if (chipIfaceCallback == nullptr) {
92 HDF_LOGE("chipIfaceCallback is null");
93 return HDF_FAILURE;
94 }
95 HDF_LOGI("register ext callback");
96 vendorHal_.lock()->RegisterExtIfaceCallBack(ifName_, chipIfaceCallback);
97 return HDF_SUCCESS;
98 }
99
UnRegisterChipIfaceCallBack(const sptr<IChipIfaceCallback> & chipIfaceCallback)100 int32_t WifiExtIface::UnRegisterChipIfaceCallBack(const sptr<IChipIfaceCallback>& chipIfaceCallback)
101 {
102 if (chipIfaceCallback == nullptr) {
103 HDF_LOGE("chipIfaceCallback is null");
104 return HDF_FAILURE;
105 }
106 HDF_LOGI("unregister ext callback");
107 vendorHal_.lock()->UnRegisterExtIfaceCallBack(ifName_, chipIfaceCallback);
108 return HDF_SUCCESS;
109 }
110
StartScan(const ScanParams & scanParam)111 int32_t WifiExtIface::StartScan(const ScanParams& scanParam)
112 {
113 return HDF_ERR_NOT_SUPPORT;
114 }
115
GetScanInfos(std::vector<ScanResultsInfo> & scanResultsInfo)116 int32_t WifiExtIface::GetScanInfos(std::vector<ScanResultsInfo>& scanResultsInfo)
117 {
118 return HDF_ERR_NOT_SUPPORT;
119 }
120
StartPnoScan(const PnoScanParams & pnoParams)121 int32_t WifiExtIface::StartPnoScan(const PnoScanParams& pnoParams)
122 {
123 return HDF_ERR_NOT_SUPPORT;
124 }
125
StopPnoScan()126 int32_t WifiExtIface::StopPnoScan()
127 {
128 return HDF_ERR_NOT_SUPPORT;
129 }
130
GetSignalPollInfo(SignalPollResult & signalPollResult)131 int32_t WifiExtIface::GetSignalPollInfo(SignalPollResult& signalPollResult)
132 {
133 return HDF_ERR_NOT_SUPPORT;
134 }
135
EnablePowerMode(int32_t mode)136 int32_t WifiExtIface::EnablePowerMode(int32_t mode)
137 {
138 return HDF_ERR_NOT_SUPPORT;
139 }
140
SetDpiMarkRule(int32_t uid,int32_t protocol,int32_t enable)141 int32_t WifiExtIface::SetDpiMarkRule(int32_t uid, int32_t protocol, int32_t enable)
142 {
143 return HDF_ERR_NOT_SUPPORT;
144 }
145
SetTxPower(int32_t power)146 int32_t WifiExtIface::SetTxPower(int32_t power)
147 {
148 return HDF_ERR_NOT_SUPPORT;
149 }
150
SetIfaceState(bool state)151 int32_t WifiExtIface::SetIfaceState(bool state)
152 {
153 return HDF_ERR_NOT_SUPPORT;
154 }
155
SendCmdToDriver(const std::string & ifName,int32_t cmdId,const std::vector<int8_t> & paramBuf)156 int32_t WifiExtIface::SendCmdToDriver(const std::string& ifName, int32_t cmdId, const std::vector<int8_t>& paramBuf)
157 {
158 WifiError status = vendorHal_.lock()->SendCmdToDriver(ifName, cmdId, paramBuf);
159 if (status == HAL_SUCCESS) {
160 return HDF_SUCCESS;
161 }
162 return HDF_FAILURE;
163 }
164
SendActionFrame(const std::string & ifName,uint32_t freq,const std::vector<uint8_t> & frameData)165 int32_t WifiExtIface::SendActionFrame(const std::string& ifName, uint32_t freq, const std::vector<uint8_t>& frameData)
166 {
167 WifiError status = vendorHal_.lock()->SendActionFrame(ifName, freq, frameData);
168 if (status == HAL_SUCCESS) {
169 return HDF_SUCCESS;
170 }
171 return HDF_FAILURE;
172 }
173
RegisterActionFrameReceiver(const std::string & ifName,const std::vector<uint8_t> & match)174 int32_t WifiExtIface::RegisterActionFrameReceiver(const std::string& ifName, const std::vector<uint8_t>& match)
175 {
176 WifiError status = vendorHal_.lock()->RegisterActionFrameReceiver(ifName, match);
177 if (status == HAL_SUCCESS) {
178 return HDF_SUCCESS;
179 }
180 return HDF_FAILURE;
181 }
182
GetCoexictenceChannelList(const std::string & ifName,std::vector<uint8_t> & paramBuf)183 int32_t WifiExtIface::GetCoexictenceChannelList(const std::string& ifName, std::vector<uint8_t>& paramBuf)
184 {
185 WifiError status = vendorHal_.lock()->GetCoexictenceChannelList(ifName, paramBuf);
186 if (status != HAL_SUCCESS) {
187 return HDF_FAILURE;
188 }
189 return HDF_SUCCESS;
190 }
191
SetProjectionScreenParam(const std::string & ifName,const ProjectionScreenCmdParam & param)192 int32_t WifiExtIface::SetProjectionScreenParam(const std::string& ifName, const ProjectionScreenCmdParam& param)
193 {
194 WifiError status = vendorHal_.lock()->SetProjectionScreenParam(ifName, param);
195 if (status != HAL_SUCCESS) {
196 return HDF_FAILURE;
197 }
198 return HDF_SUCCESS;
199 }
200 }
201 }
202 }
203 }
204 }