From de580aefb460625676a1cb6b048d904a4bf89da7 Mon Sep 17 00:00:00 2001 From: shripad621git Date: Fri, 22 Mar 2024 17:22:16 +0530 Subject: [PATCH 1/2] Added the compilation fixes for the conversion errors for lower idf versions. --- src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp | 4 ++-- src/platform/ESP32/ESP32EndpointQueueFilter.h | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp index 8fb52e7bb71629..5fefcb5490f059 100644 --- a/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp +++ b/src/platform/ESP32/ConnectivityManagerImpl_WiFi.cpp @@ -1119,8 +1119,8 @@ void ConnectivityManagerImpl::OnStationIPv6AddressAvailable(const ip_event_got_i { uint8_t dig1 = (station_mac[i] & 0xF0) >> 4; uint8_t dig2 = station_mac[i] & 0x0F; - station_mac_str[2 * i] = dig1 > 9 ? ('A' + dig1 - 0xA) : ('0' + dig1); - station_mac_str[2 * i + 1] = dig2 > 9 ? ('A' + dig2 - 0xA) : ('0' + dig2); + station_mac_str[2 * i] = static_cast(dig1 > 9 ? ('A' + dig1 - 0xA) : ('0' + dig1)); + station_mac_str[2 * i + 1] = static_cast(dig2 > 9 ? ('A' + dig2 - 0xA) : ('0' + dig2)); } if (sEndpointQueueFilter.SetMdnsHostName(chip::CharSpan(station_mac_str)) == CHIP_NO_ERROR) { diff --git a/src/platform/ESP32/ESP32EndpointQueueFilter.h b/src/platform/ESP32/ESP32EndpointQueueFilter.h index e7d154dcf458af..031ea29b64d798 100644 --- a/src/platform/ESP32/ESP32EndpointQueueFilter.h +++ b/src/platform/ESP32/ESP32EndpointQueueFilter.h @@ -103,7 +103,7 @@ class ESP32EndpointQueueFilter : public EndpointQueueFilter { if (hostNameLowerCase[i] <= 'F' && hostNameLowerCase[i] >= 'A') { - hostNameLowerCase[i] = 'a' + hostNameLowerCase[i] - 'A'; + hostNameLowerCase[i] = static_cast('a' + hostNameLowerCase[i] - 'A'); } } return PayloadContains(payload, ByteSpan(mHostNameBuffer)) || PayloadContains(payload, ByteSpan(hostNameLowerCase)); From 3ad20f9393ed517bea9f5208e0f7693b7b997e33 Mon Sep 17 00:00:00 2001 From: Shubham Patil Date: Wed, 6 Dec 2023 12:17:08 +0530 Subject: [PATCH 2/2] [ESP32] Limit number of returned WiFi scan results to configured limit (#30780) Scan results are allocated on the heap and on a resource critical device where heap is less, this may fail if there are a lot of APs in the vicinity. --- src/platform/ESP32/NetworkCommissioningDriver.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/src/platform/ESP32/NetworkCommissioningDriver.cpp b/src/platform/ESP32/NetworkCommissioningDriver.cpp index e2ef8bb660ed0b..80e54d74803e7e 100644 --- a/src/platform/ESP32/NetworkCommissioningDriver.cpp +++ b/src/platform/ESP32/NetworkCommissioningDriver.cpp @@ -345,6 +345,10 @@ void ESPWiFiDriver::OnScanWiFiNetworkDone() mpScanCallback = nullptr; return; } + + // Since this is the dynamic memory allocation, restrict it to a configured limit + ap_number = std::min(static_cast(CHIP_DEVICE_CONFIG_MAX_SCAN_NETWORKS_RESULTS), ap_number); + std::unique_ptr ap_buffer_ptr(new wifi_ap_record_t[ap_number]); if (ap_buffer_ptr == NULL) {