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

ESP32: Do not read the ap record if esp_wifi_scan_start() is not called by NetworkCommissioningDriver [Cherrypick 27161] #28045

Merged
merged 1 commit into from
Mar 12, 2024
Merged
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
32 changes: 17 additions & 15 deletions src/platform/ESP32/NetworkCommissioningDriver.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -297,27 +297,26 @@ CHIP_ERROR ESPWiFiDriver::StartScanWiFiNetworks(ByteSpan ssid)

void ESPWiFiDriver::OnScanWiFiNetworkDone()
{
if (!mpScanCallback)
{
ChipLogProgress(DeviceLayer, "No scan callback");
return;
}
uint16_t ap_number;
esp_wifi_scan_get_ap_num(&ap_number);
if (!ap_number)
{
ChipLogProgress(DeviceLayer, "No AP found");
if (mpScanCallback != nullptr)
{
mpScanCallback->OnFinished(Status::kSuccess, CharSpan(), nullptr);
mpScanCallback = nullptr;
}
mpScanCallback->OnFinished(Status::kSuccess, CharSpan(), nullptr);
mpScanCallback = nullptr;
return;
}
std::unique_ptr<wifi_ap_record_t[]> ap_buffer_ptr(new wifi_ap_record_t[ap_number]);
if (ap_buffer_ptr == NULL)
{
ChipLogError(DeviceLayer, "can't malloc memory for ap_list_buffer");
if (mpScanCallback)
{
mpScanCallback->OnFinished(Status::kUnknownError, CharSpan(), nullptr);
mpScanCallback = nullptr;
}
mpScanCallback->OnFinished(Status::kUnknownError, CharSpan(), nullptr);
mpScanCallback = nullptr;
return;
}
wifi_ap_record_t * ap_list_buffer = ap_buffer_ptr.get();
Expand All @@ -339,16 +338,19 @@ void ESPWiFiDriver::OnScanWiFiNetworkDone()
{
ap_buffer_ptr.release();
}
}
else
{
ChipLogError(DeviceLayer, "can't get ap_records ");
if (mpScanCallback)
else
{
ChipLogError(DeviceLayer, "can't schedule the scan result processing");
mpScanCallback->OnFinished(Status::kUnknownError, CharSpan(), nullptr);
mpScanCallback = nullptr;
}
}
else
{
ChipLogError(DeviceLayer, "can't get ap_records ");
mpScanCallback->OnFinished(Status::kUnknownError, CharSpan(), nullptr);
mpScanCallback = nullptr;
}
}

void ESPWiFiDriver::OnNetworkStatusChange()
Expand Down