-
Notifications
You must be signed in to change notification settings - Fork 182
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
Cannot change network interface after creation #332
Comments
If you have concrete methods that need to be exposed (as well as justification why just re-creating the interface is not ideal), please go ahead and justify. But in its current shape, this issue is hardly actionable. |
You cannot just recreate the interface. You would at least have to rotate the key, because it has to be unique. And swapping the interface does not allow setting an IP for an existing connection: log::info!("Starting...");
wifi.start()?;
log::info!("Connecting...");
wifi.connect()?;
log::info!("Connected");
wifi.wait_netif_up()?;
log::info!("Ready");
log::info!("Changing ip");
wifi.wifi_mut().swap_netif_sta(EspNetif::new_with_conf(&NetifConfiguration {
key: "test".into(),
ip_configuration: ipv4::Configuration::Client(ipv4::ClientConfiguration::Fixed(ipv4::ClientSettings {
ip: ipv4::Ipv4Addr::new(192, 168, 178, 244),
subnet: ipv4::Subnet {
gateway: ipv4::Ipv4Addr::new(192, 168, 178, 1),
mask: ipv4::Mask(24),
},
dns: Some(ipv4::Ipv4Addr::new(1, 1, 1, 1)),
secondary_dns: None,
})),
..NetifConfiguration::wifi_default_client()
}).unwrap()).unwrap();
log::info!("Changed ip");
wifi.wait_netif_up()?;
log::info!("Netif up again"); Above code will simply timeout. |
If you believe this is possible to do at runtime without destroying the As for the the above code timing out, what is the root cause? You can't just say "you need to do B. because there is some bug with A, which I don't know the reason for". |
You're correct. I assumed you're not supposed to swap network interfaces during an active connection, but maybe it's also a bug. I have not investigated it further. It's hard to tell whether it can be considered a bug because esp-idf doesn't really document what
I can do that. The esp-idf docs for |
For anyone curious about how to get around this, we have this snippet: static IF_COUNTER: AtomicUsize = AtomicUsize::new(1);
/// A global interface ID that prevents creating duplicate interface keys.
fn get_id() -> usize {
IF_COUNTER.fetch_add(1, Ordering::Relaxed)
}
// and then later:
let new_netif = EspNetif::new_with_conf(&NetifConfiguration {
ip_configuration: ipv4::Configuration::Client(...),
key: format!("ETH_CL_{}", get_id()).as_str().try_into().unwrap(),
..NetifConfiguration::eth_default_client()
})
eth.eth_mut()
.swap_netif(new_netif);
log::info!("Starting Eth");
eth.start().await;
info!("Eth started."); |
Many methods of
EspNetif
are not exposed, such as setters and dhcp control. Without this, the ip configuration of an established connection cannot be changed.The text was updated successfully, but these errors were encountered: