Skip to content

Commit cc3dc59

Browse files
committed
Add EspNetif::set_ip_info
1 parent 1d522b7 commit cc3dc59

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

src/netif.rs

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -391,6 +391,21 @@ impl EspNetif {
391391
})
392392
}
393393

394+
pub fn set_ip_info(&mut self, ip_info: ipv4::IpInfo) -> Result<(), EspError> {
395+
let raw_ip_info: Newtype<esp_netif_ip_info_t> = ip_info.into();
396+
397+
unsafe { esp_netif_dhcpc_stop(self.0) }; // ignore error
398+
unsafe { esp!(esp_netif_set_ip_info(self.0, &raw_ip_info.0)) }?;
399+
if let Some(dns) = ip_info.dns {
400+
self.set_dns(dns);
401+
}
402+
if let Some(dns) = ip_info.secondary_dns {
403+
self.set_secondary_dns(dns);
404+
}
405+
406+
Ok(())
407+
}
408+
394409
pub fn get_key(&self) -> heapless::String<32> {
395410
unsafe { from_cstr_ptr(esp_netif_get_ifkey(self.0)) }
396411
.try_into()

0 commit comments

Comments
 (0)