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

🗑️ cleanup deprecated idf 4.3 related code #431

Merged
merged 2 commits into from
Jun 3, 2024
Merged
Show file tree
Hide file tree
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
18 changes: 3 additions & 15 deletions src/eth.rs
Original file line number Diff line number Diff line change
Expand Up @@ -62,16 +62,13 @@ where
GPIO17: Peripheral<P = gpio::Gpio17>,
{
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<GPIO0, GPIO16, GPIO17> RmiiClockConfig<GPIO0, GPIO16, GPIO17>
where
GPIO0: Peripheral<P = gpio::Gpio0>,
Expand Down Expand Up @@ -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) },
Expand All @@ -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) }
};
Expand Down
2 changes: 0 additions & 2 deletions src/http/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,6 @@ pub struct Configuration {
pub client_certificate: Option<X509<'static>>,
pub private_key: Option<X509<'static>>,
pub use_global_ca_store: bool,
#[cfg(not(esp_idf_version = "4.3"))]
pub crt_bundle_attach: Option<unsafe extern "C" fn(conf: *mut core::ffi::c_void) -> esp_err_t>,
pub raw_request_body: bool,
}
Expand Down Expand Up @@ -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()
Expand Down
7 changes: 0 additions & 7 deletions src/log.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 {
Expand Down
3 changes: 0 additions & 3 deletions src/mqtt/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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<unsafe extern "C" fn(conf: *mut c_void) -> esp_err_t>,

pub server_certificate: Option<X509<'static>>,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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()
Expand Down
10 changes: 8 additions & 2 deletions src/sntp.rs
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,10 @@ use crate::private::mutex;
#[cfg(feature = "alloc")]
extern crate alloc;

#[cfg(not(any(esp_idf_version_major = "4", esp_idf_version_minor = "0")))]
#[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::*;
Expand Down Expand Up @@ -45,7 +48,10 @@ mod esp_sntp {
pub use esp_sntp_stop as sntp_stop;
}

#[cfg(any(esp_idf_version_major = "4", esp_idf_version_minor = "0"))]
Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this header for version 4.x and x.0 ?? If so i need to revert that back and change it to 5.1 and onwards

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess I meant to say "4.x" OR "5.0". But you are right, it needs fixing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done

#[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::*;
Expand Down
1 change: 0 additions & 1 deletion src/wifi.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
Loading