https://toitlang.org/ logo
check network state without net.open?
# help
a
I currently check for a device IP with
Copy code
network := net.open
network.address
or sometihng similar. But this has the side affect of actually opening the network, even if it were nt previously opened. What is the recommended way to check if the device is connected via WiFi, without calling
open
? I also tried
network.name
but this also requires you to get the network first? Do I need to do something at a lower level?
NetworkServiceClient
? etc?
f
Good question. Maybe @kasperl knows.
a
Yeh managed to get something "kind of" working for my usecase, but I feel a nicer abstraction would be great. TLDR, making developing with wifi APs or Clients easier, while both using jag or not using jag. I ended up doing a check on
firmware.config["wifi"]
to see if we have jag and or it is confused, in which case, assume that wifi is already setup, and use that, thus
net.open
else, we do
wifi.establish
with internally set stuff. But just having a
net.is-open
might also be neat, which I think might just be a check on if
service_
in net is set. Maybe
is-open
is a slightly bad name though