Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Restyle [Ameba] Update ConnectivityManagerImpl and ConfigurationManagerImpl #12077

Closed
wants to merge 2 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/platform/Ameba/ConfigurationManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,15 @@ CHIP_ERROR ConfigurationManagerImpl::GetPrimaryWiFiMACAddress(uint8_t * buf)
int i = 0;

wifi_get_mac_address(temp);
sscanf(temp, "%02x:%02x:%02x:%02x:%02x:%02x", &mac[0], &mac[1], &mac[2], &mac[3], &mac[4], &mac[5]);

char * token = strtok(temp, ":");
while (token != NULL)
{
mac[i] = (uint32_t) strtol(token, NULL, 16);
token = strtok(NULL, ":");
i++;
}

for (i = 0; i < ETH_ALEN; i++)
buf[i] = mac[i] & 0xFF;

Expand Down
83 changes: 80 additions & 3 deletions src/platform/Ameba/ConnectivityManagerImpl.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -800,19 +800,96 @@ void ConnectivityManagerImpl::DHCPProcess(void)

CHIP_ERROR ConnectivityManagerImpl::_GetWiFiSecurityType(uint8_t & securityType)
{
securityType = 0;
unsigned int _auth_type;
unsigned short _security = 0;
rtw_wifi_setting_t setting;

#ifdef CONFIG_PLATFORM_8721D
if (wext_get_enc_ext("wlan0", &_security, &setting.key_idx, setting.password) < 0)
{
securityType = 0;
}
else
{
switch (_security)
{
case IW_ENCODE_ALG_NONE:
setting.security_type = RTW_SECURITY_OPEN;
break;
case IW_ENCODE_ALG_WEP:
setting.security_type = RTW_SECURITY_WEP_PSK;
break;
case IW_ENCODE_ALG_TKIP:
setting.security_type = RTW_SECURITY_WPA_TKIP_PSK;
break;
case IW_ENCODE_ALG_CCMP:
setting.security_type = RTW_SECURITY_WPA2_AES_PSK;
break;
default:
break;
}
securityType = setting.security_type;
}
#else
wext_get_enc_ext("wlan0", &_security, &setting.key_idx, setting.password);
if (wext_get_auth_type("wlan0", &_auth_type) < 0)
{
securityType = 0;
}
else
{
switch (_security)
{
case IW_ENCODE_ALG_NONE:
setting.security_type = RTW_SECURITY_OPEN;
break;
case IW_ENCODE_ALG_WEP:
setting.security_type = RTW_SECURITY_WEP_PSK;
break;
case IW_ENCODE_ALG_TKIP:
if (_auth_type == WPA_SECURITY)
setting.security_type = RTW_SECURITY_WPA_TKIP_PSK;
else if (_auth_type == WPA2_SECURITY)
setting.security_type = RTW_SECURITY_WPA2_TKIP_PSK;
break;
case IW_ENCODE_ALG_CCMP:
if (_auth_type == WPA_SECURITY)
setting.security_type = RTW_SECURITY_WPA_AES_PSK;
else if (_auth_type == WPA2_SECURITY)
setting.security_type = RTW_SECURITY_WPA2_AES_PSK;
else if (_auth_type == WPA3_SECURITY)
setting.security_type = RTW_SECURITY_WPA3_AES_PSK;
break;
default:
break;
}
securityType = setting.security_type;
}
#endif

return CHIP_NO_ERROR;
}

CHIP_ERROR ConnectivityManagerImpl::_GetWiFiChannelNumber(uint16_t & channelNumber)
{
channelNumber = 0;
unsigned char channel;

if (wext_get_channel("wlan0", &channel) < 0)
channelNumber = 0;
else
channelNumber = (uint16_t) channel;

return CHIP_NO_ERROR;
}

CHIP_ERROR ConnectivityManagerImpl::_GetWiFiRssi(int8_t & rssi)
{
rssi = 0;
int _rssi = 0;
if (wifi_get_rssi(&_rssi) < 0)
rssi = 0;
else
rssi = _rssi;

return CHIP_NO_ERROR;
}

Expand Down