From be0fb54e64e7db4bbf1c47148acf4d67fb25af43 Mon Sep 17 00:00:00 2001 From: Frederick Vollbrecht Date: Tue, 21 May 2024 17:20:01 +0200 Subject: [PATCH 1/2] =?UTF-8?q?=F0=9F=97=91=EF=B8=8F=20cleanup=20deprecate?= =?UTF-8?q?d=20idf=204.3=20related=20code?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/eth.rs | 18 +++--------------- src/http/client.rs | 2 -- src/log.rs | 7 ------- src/mqtt/client.rs | 3 --- src/sntp.rs | 26 -------------------------- src/wifi.rs | 1 - 6 files changed, 3 insertions(+), 54 deletions(-) diff --git a/src/eth.rs b/src/eth.rs index 88130b50162..1f470ed74ec 100644 --- a/src/eth.rs +++ b/src/eth.rs @@ -62,16 +62,13 @@ where GPIO17: Peripheral

, { Input(GPIO0), - #[cfg(not(esp_idf_version = "4.3"))] OutputGpio0(GPIO0), - /// This according to ESP-IDF is for "testing" only - #[cfg(not(esp_idf_version = "4.3"))] + /// This according to ESP-IDF is for "testing" only OutputGpio16(GPIO16), - #[cfg(not(esp_idf_version = "4.3"))] OutputInvertedGpio17(GPIO17), } -#[cfg(all(esp32, esp_idf_eth_use_esp32_emac, not(esp_idf_version = "4.3")))] +#[cfg(all(esp32, esp_idf_eth_use_esp32_emac))] impl RmiiClockConfig where GPIO0: Peripheral

, @@ -265,13 +262,7 @@ impl<'d> EthDriver<'d, RmiiEth> { let phy = match chipset { RmiiEthChipset::IP101 => unsafe { esp_eth_phy_new_ip101(&phy_cfg) }, RmiiEthChipset::RTL8201 => unsafe { esp_eth_phy_new_rtl8201(&phy_cfg) }, - #[cfg(not(esp_idf_version = "4.3"))] RmiiEthChipset::LAN87XX => unsafe { esp_eth_phy_new_lan87xx(&phy_cfg) }, - #[cfg(esp_idf_version = "4.3")] - #[deprecated( - note = "Using ESP-IDF 4.3 is untested, please upgrade to 4.4 or newer. Support will be removed in the next major release." - )] - RmiiEthChipset::LAN87XX => unsafe { esp_eth_phy_new_lan8720(&phy_cfg) }, RmiiEthChipset::DP83848 => unsafe { esp_eth_phy_new_dp83848(&phy_cfg) }, #[cfg(esp_idf_version_major = "4")] RmiiEthChipset::KSZ8041 => unsafe { esp_eth_phy_new_ksz8041(&phy_cfg) }, @@ -297,10 +288,7 @@ impl<'d> EthDriver<'d, RmiiEth> { let mac = { let mut config = Self::eth_mac_default_config(mdc, mdio); - #[cfg(not(esp_idf_version = "4.3"))] - { - config.clock_config = clk_config.eth_mac_clock_config(); - } + config.clock_config = clk_config.eth_mac_clock_config(); unsafe { esp_eth_mac_new_esp32(&config) } }; diff --git a/src/http/client.rs b/src/http/client.rs index 5b03600053b..512b316a3bc 100644 --- a/src/http/client.rs +++ b/src/http/client.rs @@ -84,7 +84,6 @@ pub struct Configuration { pub client_certificate: Option>, pub private_key: Option>, pub use_global_ca_store: bool, - #[cfg(not(esp_idf_version = "4.3"))] pub crt_bundle_attach: Option esp_err_t>, pub raw_request_body: bool, } @@ -121,7 +120,6 @@ impl EspHttpConnection { user_data: &*event_handler as *const _ as *mut core::ffi::c_void, use_global_ca_store: configuration.use_global_ca_store, - #[cfg(not(esp_idf_version = "4.3"))] crt_bundle_attach: configuration.crt_bundle_attach, ..Default::default() diff --git a/src/log.rs b/src/log.rs index 925d7d12cc6..61e94b9f0bc 100644 --- a/src/log.rs +++ b/src/log.rs @@ -180,7 +180,6 @@ impl EspLogger { } } - #[cfg(not(all(esp_idf_version_major = "4", esp_idf_version_minor = "3")))] fn should_log(record: &Record) -> bool { use crate::private::mutex::Mutex; use alloc::collections::BTreeMap; @@ -210,12 +209,6 @@ impl EspLogger { let max_level = unsafe { esp_log_level_get(ctarget.as_c_str().as_ptr()) }; level <= max_level } - - #[cfg(all(esp_idf_version_major = "4", esp_idf_version_minor = "3"))] - fn should_log(_record: &Record) -> bool { - // No esp_log_level_get on ESP-IDF V4.3 - true - } } impl ::log::Log for EspLogger { diff --git a/src/mqtt/client.rs b/src/mqtt/client.rs index d2955532b01..b8d77b89138 100644 --- a/src/mqtt/client.rs +++ b/src/mqtt/client.rs @@ -73,7 +73,6 @@ pub struct MqttClientConfiguration<'a> { pub use_global_ca_store: bool, pub skip_cert_common_name_check: bool, - #[cfg(not(esp_idf_version = "4.3"))] pub crt_bundle_attach: Option esp_err_t>, pub server_certificate: Option>, @@ -116,7 +115,6 @@ impl<'a> Default for MqttClientConfiguration<'a> { use_global_ca_store: false, skip_cert_common_name_check: false, - #[cfg(not(esp_idf_version = "4.3"))] crt_bundle_attach: Default::default(), server_certificate: None, @@ -163,7 +161,6 @@ impl<'a> TryFrom<&'a MqttClientConfiguration<'a>> use_global_ca_store: conf.use_global_ca_store, skip_cert_common_name_check: conf.skip_cert_common_name_check, - #[cfg(not(esp_idf_version = "4.3"))] crt_bundle_attach: conf.crt_bundle_attach, ..Default::default() diff --git a/src/sntp.rs b/src/sntp.rs index d9ca948f43e..59143279794 100644 --- a/src/sntp.rs +++ b/src/sntp.rs @@ -13,7 +13,6 @@ use crate::private::mutex; #[cfg(feature = "alloc")] extern crate alloc; -#[cfg(not(any(esp_idf_version_major = "4", esp_idf_version_minor = "0")))] mod esp_sntp { use super::OperatingMode; pub use crate::sys::*; @@ -45,31 +44,6 @@ mod esp_sntp { pub use esp_sntp_stop as sntp_stop; } -#[cfg(any(esp_idf_version_major = "4", esp_idf_version_minor = "0"))] -mod esp_sntp { - use super::OperatingMode; - pub use crate::sys::*; - - impl From for OperatingMode { - fn from(from: u8_t) -> Self { - match from as u32 { - SNTP_OPMODE_POLL => OperatingMode::Poll, - SNTP_OPMODE_LISTENONLY => OperatingMode::ListenOnly, - _ => unreachable!(), - } - } - } - - impl From for u8_t { - fn from(from: OperatingMode) -> Self { - match from { - OperatingMode::Poll => SNTP_OPMODE_POLL as u8_t, - OperatingMode::ListenOnly => SNTP_OPMODE_LISTENONLY as u8_t, - } - } - } -} - use esp_sntp::*; const SNTP_SERVER_NUM: usize = SNTP_MAX_SERVERS as usize; diff --git a/src/wifi.rs b/src/wifi.rs index c13a08b8ede..b738429fd3b 100644 --- a/src/wifi.rs +++ b/src/wifi.rs @@ -586,7 +586,6 @@ impl<'d> WifiDriver<'d> { not(esp_idf_version_major = "4"), all( esp_idf_version_major = "4", - not(esp_idf_version_minor = "3"), any( not(esp_idf_version_minor = "4"), all( From 63a0ddf30654b211f2a082486ae764cda468847b Mon Sep 17 00:00:00 2001 From: Frederick Vollbrecht Date: Sat, 25 May 2024 11:45:55 +0200 Subject: [PATCH 2/2] revert sntp changes --- src/sntp.rs | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/src/sntp.rs b/src/sntp.rs index 59143279794..67df137c7fd 100644 --- a/src/sntp.rs +++ b/src/sntp.rs @@ -13,6 +13,10 @@ use crate::private::mutex; #[cfg(feature = "alloc")] extern crate alloc; +#[cfg(not(any( + esp_idf_version_major = "4", + all(esp_idf_version_major = "5", esp_idf_version_minor = "0"), +)))] // For ESP-IDF v5.1 and later mod esp_sntp { use super::OperatingMode; pub use crate::sys::*; @@ -44,6 +48,34 @@ mod esp_sntp { pub use esp_sntp_stop as sntp_stop; } +#[cfg(any( + esp_idf_version_major = "4", + all(esp_idf_version_major = "5", esp_idf_version_minor = "0"), +))] // Up to ESP-IDF v5.0.x +mod esp_sntp { + use super::OperatingMode; + pub use crate::sys::*; + + impl From for OperatingMode { + fn from(from: u8_t) -> Self { + match from as u32 { + SNTP_OPMODE_POLL => OperatingMode::Poll, + SNTP_OPMODE_LISTENONLY => OperatingMode::ListenOnly, + _ => unreachable!(), + } + } + } + + impl From for u8_t { + fn from(from: OperatingMode) -> Self { + match from { + OperatingMode::Poll => SNTP_OPMODE_POLL as u8_t, + OperatingMode::ListenOnly => SNTP_OPMODE_LISTENONLY as u8_t, + } + } + } +} + use esp_sntp::*; const SNTP_SERVER_NUM: usize = SNTP_MAX_SERVERS as usize;