aboutsummaryrefslogtreecommitdiff
path: root/embassy-net/src/stack.rs
diff options
context:
space:
mode:
Diffstat (limited to 'embassy-net/src/stack.rs')
-rw-r--r--embassy-net/src/stack.rs13
1 files changed, 13 insertions, 0 deletions
diff --git a/embassy-net/src/stack.rs b/embassy-net/src/stack.rs
index 83cd71707..e436beb1e 100644
--- a/embassy-net/src/stack.rs
+++ b/embassy-net/src/stack.rs
@@ -46,6 +46,7 @@ pub(crate) struct Stack {
46 iface: Interface, 46 iface: Interface,
47 pub sockets: SocketSet, 47 pub sockets: SocketSet,
48 link_up: bool, 48 link_up: bool,
49 config_up: bool,
49 next_local_port: u16, 50 next_local_port: u16,
50 configurator: &'static mut dyn Configurator, 51 configurator: &'static mut dyn Configurator,
51 waker: WakerRegistration, 52 waker: WakerRegistration,
@@ -102,6 +103,8 @@ impl Stack {
102 for (i, s) in config.dns_servers.iter().enumerate() { 103 for (i, s) in config.dns_servers.iter().enumerate() {
103 debug!(" DNS server {}: {}", i, s); 104 debug!(" DNS server {}: {}", i, s);
104 } 105 }
106
107 self.config_up = true;
105 } 108 }
106 Event::Deconfigured => { 109 Event::Deconfigured => {
107 debug!("Lost IP configuration"); 110 debug!("Lost IP configuration");
@@ -110,6 +113,7 @@ impl Stack {
110 if medium == Medium::Ethernet { 113 if medium == Medium::Ethernet {
111 self.iface.routes_mut().remove_default_ipv4_route(); 114 self.iface.routes_mut().remove_default_ipv4_route();
112 } 115 }
116 self.config_up = false;
113 } 117 }
114 } 118 }
115 } 119 }
@@ -209,6 +213,7 @@ pub fn init(device: &'static mut dyn Device, configurator: &'static mut dyn Conf
209 iface, 213 iface,
210 sockets, 214 sockets,
211 link_up: false, 215 link_up: false,
216 config_up: false,
212 configurator, 217 configurator,
213 next_local_port: local_port, 218 next_local_port: local_port,
214 waker: WakerRegistration::new(), 219 waker: WakerRegistration::new(),
@@ -221,6 +226,14 @@ pub fn is_init() -> bool {
221 STACK.borrow().borrow().is_some() 226 STACK.borrow().borrow().is_some()
222} 227}
223 228
229pub fn is_link_up() -> bool {
230 STACK.borrow().borrow().as_ref().unwrap().link_up
231}
232
233pub fn is_config_up() -> bool {
234 STACK.borrow().borrow().as_ref().unwrap().config_up
235}
236
224pub async fn run() { 237pub async fn run() {
225 futures::future::poll_fn(|cx| { 238 futures::future::poll_fn(|cx| {
226 Stack::with(|stack| stack.poll(cx)); 239 Stack::with(|stack| stack.poll(cx));