Skip to content

Commit

Permalink
Update ConnectivityManagerImpl and ConfigurationManagerImpl
Browse files Browse the repository at this point in the history
  • Loading branch information
pankore committed Nov 22, 2021
1 parent 4bb1e67 commit 25a282c
Show file tree
Hide file tree
Showing 2 changed files with 89 additions and 4 deletions.
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

0 comments on commit 25a282c

Please sign in to comment.