mirror of
https://gitee.com/openharmony/communication_wifi.git
synced 2024-11-23 15:10:16 +00:00
check hdi normal start
Signed-off-by: gaosong <gaosong29@huawei.com>
This commit is contained in:
parent
7b94408f22
commit
58837454c0
@ -26,7 +26,7 @@
|
||||
#define LOG_TAG "WifiHdiProxy"
|
||||
|
||||
#define MAX_FEATURE_NUMBER 16
|
||||
|
||||
#define MAX_OBJ_REFERENCE_COUNT 2
|
||||
const char *HDI_SERVICE_NAME = "wlan_interface_service"; // Move the define to HDF module
|
||||
|
||||
static pthread_mutex_t g_mutex;
|
||||
@ -155,6 +155,9 @@ WifiErrorNo StartHdiWifi()
|
||||
pthread_mutex_lock(&g_mutex);
|
||||
if (g_wlanRefCount != 0) {
|
||||
++g_wlanRefCount;
|
||||
if (g_wlanRefCount > MAX_OBJ_REFERENCE_COUNT) {
|
||||
g_wlanRefCount = MAX_OBJ_REFERENCE_COUNT;
|
||||
}
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
LOGI("%{public}s: wlan ref count:%{public}d", __func__, g_wlanRefCount);
|
||||
return WIFI_IDL_OPT_OK;
|
||||
@ -221,7 +224,7 @@ WifiErrorNo HdiStop()
|
||||
LOGE("%{public}s: failed to stop, ret:%{public}d", __func__, ret);
|
||||
}
|
||||
IWlanInterfaceReleaseInstance(HDI_SERVICE_NAME, g_wlanObj, false);
|
||||
--g_wlanRefCount;
|
||||
g_wlanRefCount = 0;
|
||||
g_wlanObj = NULL;
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
LOGI("%{public}s: success to release instance", __func__);
|
||||
@ -276,4 +279,25 @@ void CleanLocalResources()
|
||||
g_wlanRefCount = 0;
|
||||
pthread_mutex_unlock(&g_mutex);
|
||||
}
|
||||
|
||||
WifiErrorNo CheckHdiNormalStart(const int32_t wlanType)
|
||||
{
|
||||
WifiErrorNo ret = WIFI_IDL_OPT_OK;
|
||||
WifiHdiProxy proxy = GetHdiProxy(wlanType);
|
||||
if (proxy.wlanObj == NULL || proxy.feature == NULL) {
|
||||
LOGE("CheckHdiNormalStart: Hdi proxy is null, hdi abnormal start!");
|
||||
ret = HdiStop();
|
||||
if (ret != WIFI_IDL_OPT_OK) {
|
||||
LOGE("CheckHdiNormalStart: HdiStop failed!");
|
||||
retrun ret;
|
||||
}
|
||||
ret = StartHdiWifi();
|
||||
if (ret != WIFI_IDL_OPT_OK) {
|
||||
LOGE("CheckHdiNormalStart: StartHdiWifi failed!");
|
||||
retrun ret;
|
||||
}
|
||||
}
|
||||
LOGI("CheckHdiNormalStart: hdi normal start!");
|
||||
return ret;
|
||||
}
|
||||
#endif
|
||||
|
@ -88,6 +88,14 @@ bool IsHdiRemoteDied();
|
||||
* @Description Clean local resources if remote died.
|
||||
*/
|
||||
void CleanLocalResources();
|
||||
|
||||
/**
|
||||
* @Description check hdi normal start
|
||||
*
|
||||
* @param wlanType - wlan type
|
||||
* @return WifiErrorNo - operation result
|
||||
*/
|
||||
WifiErrorNo CheckHdiNormalStart(const int32_t wlanType);
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
@ -167,6 +167,10 @@ WifiErrorNo HdiWifiStart()
|
||||
LOGE("failed to start hdi wifi!");
|
||||
return WIFI_IDL_OPT_FAILED;
|
||||
}
|
||||
if (CheckHdiNormalStart(PROTOCOL_80211_IFTYPE_STATION) != WIFI_IDL_OPT_OK) {
|
||||
LOGE("check hdi abnormal start, failed to start hdi wifi!");
|
||||
return WIFI_IDL_OPT_FAILED;
|
||||
}
|
||||
struct IWlanCallback cEventCallback;
|
||||
if (memset_s(&cEventCallback, sizeof(cEventCallback), 0, sizeof(cEventCallback)) != EOK) {
|
||||
LOGE("%{public}s: failed to memset", __func__);
|
||||
|
@ -231,7 +231,18 @@ WifiErrorNo WifiHdiClient::ReqGetConnectSignalInfo(const std::string &endBssid,
|
||||
/* ************************ softAp Interface ************************** */
|
||||
WifiErrorNo WifiHdiClient::StartAp(int id)
|
||||
{
|
||||
return StartHdiWifi();
|
||||
WifiErrorNo ret = WIFI_IDL_OPT_OK;
|
||||
ret = StartHdiWifi();
|
||||
if (ret != WIFI_IDL_OPT_OK) {
|
||||
LOGE("%{public}s: failed to StartHdiWifi", __func__);
|
||||
return ret;
|
||||
}
|
||||
ret = CheckHdiNormalStart(PROTOCOL_80211_IFTYPE_AP);
|
||||
if (ret != WIFI_IDL_OPT_OK) {
|
||||
LOGE("%{public}s: check hdi abnormal start, failed to start hdi wifi!", __func__);
|
||||
return ret;
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
WifiErrorNo WifiHdiClient::StopAp(int id)
|
||||
|
Loading…
Reference in New Issue
Block a user