_WifiConvertErrorResult(errorCode == WIFI_ERROR_INVALID_KEY, r, E_AUTHENTICATION);
_WifiConvertErrorResult(errorCode == WIFI_ERROR_NO_REPLY, r, E_NOT_RESPONDING);
_WifiConvertErrorResult(errorCode == WIFI_ERROR_DHCP_FAILED, r, E_DHCP);
+ SysTryLog(NID_NET_WIFI, errorCode == WIFI_ERROR_NONE, "Failed result from OnWifiConnected() is 0x%x.", errorCode);
_IWifiManagerEventListener* pMgrEvtListener = null;
IEnumeratorT<_IWifiManagerEventListener*>* pEnum = null;
char* pEssid = null;
wifi_ap_h apHandler;
int err = wifi_get_connected_ap(&apHandler);
- _WifiConvertErrorResult(errorCode != WIFI_ERROR_NONE, r, E_FAILURE);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_get_connected_ap() is 0x%x.", err);
+ _WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
_WifiConvertErrorResult(err == WIFI_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
- wifi_ap_get_essid(apHandler, &pEssid);
+ err = wifi_ap_get_essid(apHandler, &pEssid);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_get_essid() is 0x%x.", err);
String ssid(pEssid);
free(pEssid);
case WIFI_CONNECTION_STATE_CONNECTED:
{
char* pEssid = null;
- wifi_ap_get_essid(apHandler, &pEssid);
+ int err = wifi_ap_get_essid(apHandler, &pEssid);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_get_essid() is 0x%x.", err);
String ssid(pEssid);
free(pEssid);
LinkedList* pBssInfoList = static_cast<LinkedList*>(pUserData);
wifi_ap_h pApHandleClone = null;
- wifi_ap_clone(&pApHandleClone, pApHandle);
+ int err = wifi_ap_clone(&pApHandleClone, pApHandle);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_clone() is 0x%x.", err);
pBssInfo = _WifiUtility::CreateWifiBssInfoInstanceN(pApHandleClone);
// keep gonig even though creating one WifiBssInfo instance.
SysTryReturn(NID_NET_WIFI, pBssInfo != null, true, GetLastResult(),
WifiConnectionState* pLocalState = static_cast<WifiConnectionState*>(pUserData);
bool isContinued = true;
- wifi_ap_get_connection_state(pApHandle, &apState);
+ int err = wifi_ap_get_connection_state(pApHandle, &apState);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_get_connection_state() is 0x%x.", err);
switch (apState)
{
pBssInfoList = new (std::nothrow) LinkedList(SingleObjectDeleter);
SysTryReturnVoidResult(NID_NET_WIFI, pBssInfoList != null, E_OUT_OF_MEMORY, "[E_OUT_OF_MEMORY] Memory allocation failed.");
- wifi_foreach_found_aps(OnWifiEachAccessPointFound, pBssInfoList);
+ int err = wifi_foreach_found_aps(OnWifiEachAccessPointFound, pBssInfoList);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_foreach_found_aps() is 0x%x.", err);
_IWifiManagerEventListener* pMgrEvtListener = null;
IEnumeratorT<_IWifiManagerEventListener*>* pEnum = null;
result
_WifiSystemAdapter::Connect(const WifiBssInfo& targetApInfo)
{
- result r = E_SUCCESS;
+ result r = E_SUCCESS;
int err = WIFI_ERROR_NONE;
wifi_ap_h ap;
unique_ptr<char[]> pSsidTemp(_StringConverter::CopyToCharArrayN(targetApInfo.GetSsid()));
SysTryReturnResult(NID_NET_WIFI, pSsidTemp != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
err = wifi_ap_create(pSsidTemp.get(), &ap);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_create() is 0x%x.", err);
_WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
_WifiConvertErrorResult(err == WIFI_ERROR_OUT_OF_MEMORY, r, E_OUT_OF_MEMORY);
SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to create handle of ap.");
// Sets Authentication Type
securityType = _WifiUtility::ConvertSecurityType(pSecurityInfo->GetAuthenticationType());
err = wifi_ap_set_security_type(ap, securityType);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_set_security_type() is 0x%x.", err);
_WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set authenticatino type.");
unique_ptr<char[]> pKeyTemp(_StringConverter::CopyToCharArrayN(pSecurityInfoImpl->GetNetworkKey()));
SysTryReturnResult(NID_NET_WIFI, pKeyTemp != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
err = wifi_ap_set_passphrase(ap,pKeyTemp.get());
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_set_passphrase() is 0x%x.", err);
_WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set network key.");
}
{
ap = static_cast <wifi_ap_h> (pBssInfoImpl->GetBssHandle());
- const unsigned char* pSecurityKey = null;
+ unique_ptr<char[]> pKeyTemp;
+ const char* pSecurityKey = null;
+ if (pSecurityInfoImpl->GetNetworkKey().IsEmpty())
+ {
+ switch (targetApInfo.GetSecurityInfo()->GetEncryptionType())
+ {
+ case WIFI_ENCRYPTION_NONE:
+ break;
+
+ case WIFI_ENCRYPTION_WEP:
+ pSecurityKey = reinterpret_cast <const char*>(pSecurityInfoImpl->GetNetworkKeyWep());
+ break;
+
+ case WIFI_ENCRYPTION_TKIP:
+ pSecurityKey = reinterpret_cast <const char*>(pSecurityInfoImpl->GetNetworkKeyTkip());
+ break;
+
+ case WIFI_ENCRYPTION_AES:
+ pSecurityKey = reinterpret_cast <const char*>(pSecurityInfoImpl->GetNetworkKeyAes());
+ break;
+
+ case WIFI_ENCRYPTION_TKIP_AES_MIXED:
+ pSecurityKey = reinterpret_cast <const char*>(pSecurityInfoImpl->GetNetworkKeyTkip());
+
+ if (strlen(pSecurityKey) == 0)
+ {
+ pSecurityKey = reinterpret_cast <const char*>(pSecurityInfoImpl->GetNetworkKeyAes());
+ }
+ break;
+ default:
+ break;
+ }
+ }
+ else
+ {
+ if (targetApInfo.GetSecurityInfo()->GetEncryptionType() != WIFI_ENCRYPTION_NONE)
+ {
+ pKeyTemp.reset(_StringConverter::CopyToCharArrayN(pSecurityInfoImpl->GetNetworkKey()));
+ SysTryReturnResult(NID_NET_WIFI, pKeyTemp != null, E_OUT_OF_MEMORY, "Memory allocation failed.");
+ pSecurityKey = pKeyTemp.get();
+ }
+ }
- switch (targetApInfo.GetSecurityInfo()->GetEncryptionType())
- {
- case WIFI_ENCRYPTION_NONE:
- break;
-
- case WIFI_ENCRYPTION_WEP:
- {
- pSecurityKey = pSecurityInfoImpl->GetNetworkKeyWep();
- wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey));
- }
- break;
-
- case WIFI_ENCRYPTION_TKIP:
- {
- SysLog(NID_NET_WIFI, "WIFI_ENCRYPTION_TKIP");
-
- pSecurityKey = pSecurityInfoImpl->GetNetworkKeyTkip();
-
- wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey));
- }
- break;
-
- case WIFI_ENCRYPTION_AES:
- {
- pSecurityKey = pSecurityInfoImpl->GetNetworkKeyAes();
-
- wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey)); }
- break;
-
- case WIFI_ENCRYPTION_TKIP_AES_MIXED:
- {
- pSecurityKey = pSecurityInfoImpl->GetNetworkKeyTkip();
-
- if (strlen(reinterpret_cast <const char*>(pSecurityKey)) == 0)
- {
- pSecurityKey = pSecurityInfoImpl->GetNetworkKeyAes();
-
- if (strlen(reinterpret_cast <const char*>(pSecurityKey)) > 0)
- {
- wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey));
- }
- }
- else
- {
- wifi_ap_set_passphrase(ap,reinterpret_cast <const char*>(pSecurityKey));
- }
- }
- break;
- default:
- break;
- }
+ err = wifi_ap_set_passphrase(ap, pSecurityKey);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_set_passphrase() is 0x%x.", err);
+ _WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
+ SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set network key.");
}
if (pSecurityInfoImpl->GetAuthenticationType() == WIFI_AUTHENTICATION_WPA ||
{
wifi_eap_type_e eapType = _WifiUtility::ConvertEapType(pSecurityInfoImpl->GetEapType());
err = wifi_ap_set_eap_type(ap, eapType);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_set_eap_type() is 0x%x.", err);
_WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
_WifiConvertErrorResult(err == WIFI_ERROR_INVALID_PARAMETER, r, E_INVALID_ARG);
SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set eap type.");
wifi_eap_auth_type_e eapAuthType = _WifiUtility::ConvertEapAuthType(pSecurityInfoImpl->GetEapType());
err = wifi_ap_set_eap_auth_type(ap, eapAuthType);
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_set_eap_auth_type() is 0x%x.", err);
_WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
_WifiConvertErrorResult(err == WIFI_ERROR_INVALID_PARAMETER, r, E_INVALID_ARG);
SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set eap authentication type.");
err = wifi_ap_set_eap_passphrase(ap, pSecurityInfoImpl->GetEapUserId(), pSecurityInfoImpl->GetEapPassword());
+ SysTryLog(NID_NET_WIFI, err == WIFI_ERROR_NONE, "Failed result from wifi_ap_set_eap_passphrase() is 0x%x.", err);
_WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
_WifiConvertErrorResult(err == WIFI_ERROR_INVALID_PARAMETER, r, E_INVALID_ARG);
SysTryReturnResult(NID_NET_WIFI, r == E_SUCCESS, r, "Failed to set eap authentication type.");
err = wifi_connect(ap, OnWifiConnected, null);
_WifiConvertErrorResult(err != WIFI_ERROR_NONE, r, E_FAILURE);
+
return E_SUCCESS;
}
switch (securityMode)
{
case WIFI_SECURITY_TYPE_NONE:
- {
- authenticationType = WIFI_AUTHENTICATION_OPEN;
+ authenticationType = WIFI_AUTHENTICATION_OPEN;
break;
- }
+
case WIFI_SECURITY_TYPE_WEP:
- {
- authenticationType = WIFI_AUTHENTICATION_SHARED;
+ authenticationType = WIFI_AUTHENTICATION_SHARED;
break;
- }
+
case WIFI_SECURITY_TYPE_EAP:
- {
+
if (encryptionMode == WIFI_ENCRYPTION_TYPE_TKIP)
{
authenticationType = WIFI_AUTHENTICATION_WPA;
{
authenticationType = WIFI_AUTHENTICATION_WPA2;
}
- break;
- }
+ break;
+
case WIFI_SECURITY_TYPE_WPA_PSK:
- {
if (encryptionMode == WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED)
{
authenticationType = WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK;
authenticationType = WIFI_AUTHENTICATION_WPA_PSK;
}
break;
- }
+
case WIFI_SECURITY_TYPE_WPA2_PSK:
- {
+
if (encryptionMode == WIFI_ENCRYPTION_TYPE_TKIP_AES_MIXED)
{
authenticationType = WIFI_AUTHENTICATION_WPA_WPA2_MIXED_PSK;
authenticationType = WIFI_AUTHENTICATION_WPA2_PSK;
}
break;
- }
+
default:
break;
}
_WifiBssInfoImpl* pBssInfoImpl = null;
result r = E_SUCCESS;
int apRes = WIFI_ERROR_NONE;
- bool isKnown = false;
- char* pSsid = null;
- char* pBssid = null;
+
WifiSecurityInfo secuInfo;
_WifiSecurityInfoImpl* pSecuInfoImpl = null;
- wifi_security_type_e secType;
- wifi_encryption_type_e encType;
- int frequency = -1;
- int rssi = -1;
- int speed = -1;
+
wifi_ip_config_type_e ipType = WIFI_IP_CONFIG_TYPE_NONE;
NetAddressScheme netIpScheme = NET_ADDRESS_SCHEME_NONE;
char* pAddrStr = null;
pBssInfoImpl->SetBssHandle(apHandle);
// SSID
+ char* pSsid = null;
apRes = wifi_ap_get_essid(apHandle, &pSsid);
SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
"[E_OPERATION_FAILED] Getting the SSID of the AP has failed. [0x%08X].", apRes);
free(pSsid);
// BSSID
+ char* pBssid = null;
apRes = wifi_ap_get_bssid(apHandle, &pBssid);
SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
"[E_OPERATION_FAILED] Getting the BSSID of the AP has failed. [0x%08X].", apRes);
free(pBssid);
// Security type - Authentication type & Encryption type
+ wifi_security_type_e secType;
apRes = wifi_ap_get_security_type(apHandle, &secType);
SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
"[E_OPERATION_FAILED] Getting the security type of the AP has failed. [0x%08X].", apRes);
+ wifi_encryption_type_e encType;
apRes = wifi_ap_get_encryption_type(apHandle, &encType);
SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
"[E_OPERATION_FAILED] Getting the encryption type of the AP has failed. [0x%08X].", apRes);
+ SysLog(NID_NET_WIFI, "SSID : %ls security type : %d encryption type : %d", pBssInfoImpl->GetSsid().GetPointer(), secType, encType);
+
pSecuInfoImpl = _WifiSecurityInfoImpl::GetInstance(secuInfo);
pSecuInfoImpl->SetAuthenticationType(ConvertAuthType(secType, encType));
pSecuInfoImpl->SetEncryptionType(ConvertEncryptionType(encType));
pBssInfoImpl->SetBssType(WIFI_BSS_TYPE_INFRASTRUCTURE);
// Radio Channel
+ int frequency = -1;
apRes = wifi_ap_get_frequency(apHandle, &frequency);
SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
"[E_OPERATION_FAILED] Getting the frequency band of the AP has failed. [0x%08X].", apRes);
pBssInfoImpl->SetRadioChannel(ConvertRadioChannel(frequency));
// RSSI
+ int rssi = -1;
apRes = wifi_ap_get_rssi(apHandle, &rssi);
SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
"[E_OPERATION_FAILED] Getting the RSSI value of the AP has failed. [0x%08X].", apRes);
pBssInfoImpl->SetRssi(ConvertPercentagetoRssiValue(rssi));
// Data Rate
- apRes = wifi_ap_get_max_speed(apHandle, &speed);
+ int dataRate = -1;
+ apRes = wifi_ap_get_max_speed(apHandle, &dataRate);
SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
"[E_OPERATION_FAILED] Getting the MAX speed of the AP has failed. [0x%08X].", apRes);
- pBssInfoImpl->SetDataRate(speed);
+ pBssInfoImpl->SetDataRate(dataRate);
// Known.
+ bool isKnown = false;
apRes = wifi_ap_is_favorite(apHandle, &isKnown);
SysTryReturn(NID_NET_WIFI, apRes == WIFI_ERROR_NONE, null, E_OPERATION_FAILED,
"[E_OPERATION_FAILED] Checking the AP is a known device has failed. [0x%08X].", apRes);