Skip to content

Commit cf40c85

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

File tree

1 file changed

+14
-0
lines changed

1 file changed

+14
-0
lines changed

src/netif.rs

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

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

0 commit comments

Comments
 (0)