Update ESP32 Device Layer adaptation to use ESP-IDF 3.2
-- Removed reference to deprecated ESP AES function.
-- Changed logic around definition of LWIP_DNS_FOUND_CALLBACK_TYPE in DNSResolver code.
Previously, the logic surrounding the definition of LWIP_DNS_FOUND_CALLBACK_TYPE was written
with the presumption that the define existed in later versions of LwIP, and therefore only
needed to be declared in versions < 2. However LWIP_DNS_FOUND_CALLBACK_TYPE has *never*
been a feature of stock LwIP. Rather, it appears to be a Nest-ism intruduced in an internal
fork of LwIP. This change corrects the definition logic such that DNSResolver works with
the LwIP version included in ESP-IDF 3.2.
-- Ignore -Wdeprecated-declarations warnings when calling esp_wifi_get/set_auto_connect().
Later versions of ESP-IDF mark esp_wifi_get_auto_connect() and esp_wifi_set_auto_connect()
as depricated, leading to compilation errors. Unfortunately, no obvious alternative exists,
and the comments and commit message provide no guidence. A inquiry has been made to the
Expressif team. Pending their answer, the decision has been made to continue using the
existing APIs.
diff --git a/src/adaptations/device-layer/ESP32/AESBlockCipher.cpp b/src/adaptations/device-layer/ESP32/AESBlockCipher.cpp
index d22523b..f12f3e7 100644
--- a/src/adaptations/device-layer/ESP32/AESBlockCipher.cpp
+++ b/src/adaptations/device-layer/ESP32/AESBlockCipher.cpp
@@ -64,7 +64,7 @@
esp_aes_init(&ctx);
esp_aes_setkey(&ctx, mKey, kKeyLengthBits);
- esp_aes_encrypt(&ctx, inBlock, outBlock);
+ esp_aes_crypt_ecb(&ctx, ESP_AES_ENCRYPT, inBlock, outBlock);
esp_aes_free(&ctx);
}
@@ -79,7 +79,7 @@
esp_aes_init(&ctx);
esp_aes_setkey(&ctx, mKey, kKeyLengthBits);
- esp_aes_decrypt(&ctx, inBlock, outBlock);
+ esp_aes_crypt_ecb(&ctx, ESP_AES_DECRYPT, inBlock, outBlock);
esp_aes_free(&ctx);
}
@@ -109,7 +109,7 @@
esp_aes_init(&ctx);
esp_aes_setkey(&ctx, mKey, kKeyLengthBits);
- esp_aes_encrypt(&ctx, inBlock, outBlock);
+ esp_aes_crypt_ecb(&ctx, ESP_AES_ENCRYPT, inBlock, outBlock);
esp_aes_free(&ctx);
}
@@ -124,7 +124,7 @@
esp_aes_init(&ctx);
esp_aes_setkey(&ctx, mKey, kKeyLengthBits);
- esp_aes_decrypt(&ctx, inBlock, outBlock);
+ esp_aes_crypt_ecb(&ctx, ESP_AES_DECRYPT, inBlock, outBlock);
esp_aes_free(&ctx);
}
diff --git a/src/adaptations/device-layer/ESP32/ConnectivityManagerImpl.cpp b/src/adaptations/device-layer/ESP32/ConnectivityManagerImpl.cpp
index 93e26bd..1d9ecf4 100644
--- a/src/adaptations/device-layer/ESP32/ConnectivityManagerImpl.cpp
+++ b/src/adaptations/device-layer/ESP32/ConnectivityManagerImpl.cpp
@@ -78,7 +78,11 @@
if (mWiFiStationMode != kWiFiStationMode_ApplicationControlled)
{
bool autoConnect;
- mWiFiStationMode = (esp_wifi_get_auto_connect(&autoConnect) == ESP_OK && autoConnect)
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
+ WEAVE_ERROR err = esp_wifi_get_auto_connect(&autoConnect);
+#pragma GCC diagnostic pop
+ mWiFiStationMode = (err == ESP_OK && autoConnect)
? kWiFiStationMode_Enabled
: kWiFiStationMode_Disabled;
}
@@ -99,7 +103,10 @@
if (val != kWiFiStationMode_ApplicationControlled)
{
bool autoConnect = (val == kWiFiStationMode_Enabled);
+#pragma GCC diagnostic push
+#pragma GCC diagnostic ignored "-Wdeprecated-declarations"
err = esp_wifi_set_auto_connect(autoConnect);
+#pragma GCC diagnostic pop
SuccessOrExit(err);
SystemLayer.ScheduleWork(DriveStationState, NULL);
diff --git a/src/inet/DNSResolver.cpp b/src/inet/DNSResolver.cpp
index 126941e..7512827 100644
--- a/src/inet/DNSResolver.cpp
+++ b/src/inet/DNSResolver.cpp
@@ -36,9 +36,9 @@
#include <lwip/dns.h>
#include <lwip/tcpip.h>
-#if LWIP_VERSION_MAJOR < 2
+#ifndef LWIP_DNS_FOUND_CALLBACK_TYPE
#define LWIP_DNS_FOUND_CALLBACK_TYPE dns_found_callback
-#endif // LWIP_VERSION_MAJOR < 2
+#endif
#endif // WEAVE_SYSTEM_CONFIG_USE_LWIP
#if WEAVE_SYSTEM_CONFIG_USE_SOCKETS