• Home
  • Line#
  • Scopes#
  • Navigate#
  • Raw
  • Download
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 #include "wifi_chip_capability.h"
17 #include <sstream>
18 #include "wifi_chip_hal_interface.h"
19 #include "wifi_logger.h"
20 
21 namespace OHOS {
22 namespace Wifi {
23 DEFINE_WIFILOG_LABEL("ChipCapability");
GetInstance()24 ChipCapability& ChipCapability::GetInstance()
25 {
26     static ChipCapability inst;
27     return inst;
28 }
29 
ChipCapability()30 ChipCapability::ChipCapability()
31 {
32     m_isInitialized = false;
33     m_isSupportDbdc = false;
34     m_isSupportCsa = false;
35     m_isSupportRadarDetect = false;
36     m_isSupportDfsChannel = false;
37     m_isSupportIndoorChannel = false;
38 }
39 
~ChipCapability()40 ChipCapability::~ChipCapability()
41 {
42 }
43 
InitializeChipCapability()44 bool ChipCapability::InitializeChipCapability()
45 {
46     WIFI_LOGI("Enter InitializeChipCapability");
47     if (m_isInitialized) {
48         WIFI_LOGI("ChipCapability has been initialized");
49         return true;
50     }
51 
52     m_isInitialized = true;
53     WifiErrorNo ret = WIFI_IDL_OPT_FAILED;
54     ret = WifiChipHalInterface::GetInstance().IsSupportDbdc(m_isSupportDbdc);
55     if (ret != WIFI_IDL_OPT_OK) {
56         m_isInitialized = false;
57         WIFI_LOGE("Get IsSupportDbdc failed");
58     }
59     ret = WifiChipHalInterface::GetInstance().IsSupportCsa(m_isSupportCsa);
60     if (ret != WIFI_IDL_OPT_OK) {
61         m_isInitialized = false;
62         WIFI_LOGE("Get IsSupportCsa failed");
63     }
64     ret = WifiChipHalInterface::GetInstance().IsSupportRadarDetect(m_isSupportRadarDetect);
65     if (ret != WIFI_IDL_OPT_OK) {
66         m_isInitialized = false;
67         WIFI_LOGE("Get IsP2pSupportRadarDetect failed");
68     }
69     ret = WifiChipHalInterface::GetInstance().IsSupportDfsChannel(m_isSupportDfsChannel);
70     if (ret != WIFI_IDL_OPT_OK) {
71         m_isInitialized = false;
72         WIFI_LOGE("Get IsP2pSupportDfsChannel failed");
73     }
74     ret = WifiChipHalInterface::GetInstance().IsSupportIndoorChannel(m_isSupportIndoorChannel);
75     if (ret != WIFI_IDL_OPT_OK) {
76         m_isInitialized = false;
77         WIFI_LOGE("Get IsP2pSupportIndoorChannel failed");
78     }
79     ToString();
80     return m_isInitialized;
81 }
82 
IsSupportDbdc(void)83 bool ChipCapability::IsSupportDbdc(void)
84 {
85     return m_isSupportDbdc;
86 }
87 
IsSupportCsa(void)88 bool ChipCapability::IsSupportCsa(void)
89 {
90     return m_isSupportCsa;
91 }
92 
IsSupportRadarDetect(void)93 bool ChipCapability::IsSupportRadarDetect(void)
94 {
95     return m_isSupportRadarDetect;
96 }
97 
IsSupportDfsChannel(void)98 bool ChipCapability::IsSupportDfsChannel(void)
99 {
100     return m_isSupportDfsChannel;
101 }
102 
IsSupportIndoorChannel(void)103 bool ChipCapability::IsSupportIndoorChannel(void)
104 {
105     return m_isSupportIndoorChannel;
106 }
107 
ToString(void)108 std::string ChipCapability::ToString(void)
109 {
110     std::stringstream ss;
111     ss << "[WifiChipCap]:" << "\n";
112     ss << "Dbdc = " << m_isSupportDbdc << "\n";
113     ss << "Csa = " << m_isSupportCsa << "\n";
114     ss << "RadarDetect = " << m_isSupportRadarDetect << "\n";
115     ss << "DfsChannel = " << m_isSupportDfsChannel << "\n";
116     ss << "IndoorChannel = " << m_isSupportIndoorChannel << "\n";
117     WIFI_LOGI("%{public}s", ss.str().c_str());
118     return ss.str();
119 }
120 }  // namespace Wifi
121 }  // namespace OHOS