Skip to content

Commit

Permalink
Fix WiFi build (#17290)
Browse files Browse the repository at this point in the history
fix compilation issue and race condition in wifi build
  • Loading branch information
jmartinez-silabs authored Apr 12, 2022
1 parent bc7f2c3 commit c19aa60
Show file tree
Hide file tree
Showing 4 changed files with 26 additions and 48 deletions.
30 changes: 17 additions & 13 deletions src/platform/EFR32/NetworkCommissioningWiFiDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -175,30 +175,34 @@ void SlWiFiDriver::ConnectNetwork(ByteSpan networkId, ConnectCallback * callback
}
}

uint8_t SlWiFiDriver::ConvertSecuritytype(uint8_t security)
chip::BitFlags<WiFiSecurity> SlWiFiDriver::ConvertSecuritytype(uint8_t security)
{
uint8_t securityType = EMBER_ZCL_SECURITY_TYPE_UNSPECIFIED;
chip::BitFlags<WiFiSecurity> securityType;
if (security == WFX_SEC_NONE)
{
securityType = EMBER_ZCL_SECURITY_TYPE_NONE;
securityType = WiFiSecurity::kUnencrypted;
}
else if (security == WFX_SEC_WPA3)
else if (security & WFX_SEC_WEP)
{
securityType = WiFiSecurity::kWepPersonal;
}
else if (security & WFX_SEC_WPA)
{
securityType = EMBER_ZCL_SECURITY_TYPE_WPA3;
securityType = WiFiSecurity::kWpaPersonal;
}
else if (security & WFX_SEC_WPA2)
{
securityType = EMBER_ZCL_SECURITY_TYPE_WPA2;
securityType = WiFiSecurity::kWpa2Personal;
}
else if (security & WFX_SEC_WPA)
else if (security == WFX_SEC_WPA3)
{
securityType = EMBER_ZCL_SECURITY_TYPE_WPA;
securityType = WiFiSecurity::kWpa3Personal;
}
else if (security & WFX_SEC_WEP)
else
{
securityType = EMBER_ZCL_SECURITY_TYPE_WEP;
// wfx_sec_t support more type
securityType = WiFiSecurity::kUnencrypted;
}
// wfx_sec_t support more type

return securityType;
}
Expand Down Expand Up @@ -235,9 +239,9 @@ void SlWiFiDriver::OnScanWiFiNetworkDone(wfx_wifi_scan_result_t * aScanResult)
}
else
{
NetworkCommissioning::WiFiScanResponse scanResponse = { 0 };
NetworkCommissioning::WiFiScanResponse scanResponse = {};

scanResponse.security.SetRaw(GetInstance().ConvertSecuritytype(aScanResult->security));
scanResponse.security.Set(GetInstance().ConvertSecuritytype(aScanResult->security));
scanResponse.channel = aScanResult->chan;
scanResponse.rssi = aScanResult->rssi;
scanResponse.ssidLen = strnlen(aScanResult->ssid, DeviceLayer::Internal::kMaxWiFiSSIDLength);
Expand Down
35 changes: 1 addition & 34 deletions src/platform/EFR32/NetworkCommissioningWiFiDriver.h
Original file line number Diff line number Diff line change
Expand Up @@ -30,39 +30,6 @@ constexpr uint8_t kWiFiScanNetworksTimeOutSeconds = 10;
constexpr uint8_t kWiFiConnectNetworkTimeoutSeconds = 20;
} // namespace

// class SlScanResponseIterator : public Iterator<WiFiScanResponse>
// {
// public:
// SlScanResponseIterator(const size_t size, const wifi_ap_record_t * scanResults) : mSize(size), mpScanResults(scanResults) {}
// size_t Count() override { return mSize; }
// bool Next(WiFiScanResponse & item) override
// {
// if (mIternum >= mSize)
// {
// return false;
// }

// item.security.SetRaw(mpScanResults[mIternum].authmode);
// item.ssidLen =
// strnlen(reinterpret_cast<const char *>(mpScanResults[mIternum].ssid),
// chip::DeviceLayer::Internal::kMaxWiFiSSIDLength);
// item.channel = mpScanResults[mIternum].primary;
// item.wiFiBand = chip::DeviceLayer::NetworkCommissioning::WiFiBand::k2g4;
// item.rssi = mpScanResults[mIternum].rssi;
// memcpy(item.ssid, mpScanResults[mIternum].ssid, item.ssidLen);
// memcpy(item.bssid, mpScanResults[mIternum].bssid, 6);

// mIternum++;
// return true;
// }
// void Release() override {}

// private:
// const size_t mSize;
// const wifi_ap_record_t * mpScanResults;
// size_t mIternum = 0;
// };

template <typename T>
class SlScanResponseIterator : public Iterator<T>
{
Expand Down Expand Up @@ -153,7 +120,7 @@ class SlWiFiDriver final : public WiFiDriver

CHIP_ERROR ConnectWiFiNetwork(const char * ssid, uint8_t ssidLen, const char * key, uint8_t keyLen);

uint8_t ConvertSecuritytype(uint8_t security);
chip::BitFlags<WiFiSecurity> ConvertSecuritytype(uint8_t security);

void OnConnectWiFiNetwork();
static SlWiFiDriver & GetInstance()
Expand Down
7 changes: 7 additions & 0 deletions third_party/efr32_sdk/efr32_sdk.gni
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,13 @@ template("efr32_sdk") {
"-Wno-shadow",
]

if (defined(invoker.use_rs911x)) {
if (invoker.use_rs911x == true) {
#add compilation flags for rs991x build. This will be addressed directly in wiseconnect sdk in the next version release of that sdk
cflags += invoker.rs911x_cflags
}
}

if (defined(invoker.defines)) {
defines += invoker.defines
}
Expand Down
2 changes: 1 addition & 1 deletion third_party/efr32_sdk/repo

0 comments on commit c19aa60

Please sign in to comment.