Detect if wifi is connected

Which device and which host OS version are you using? Connman is on the resinOS 1.x series, while resinOS 2.x has NetworkManager. I’m guessing you are using the latter, that’s why the issue you experience.

Just tried your version of the request on a Raspberry Pi 3 with host OS 1.24.1 (which uses Connman), and the result I get is:

method return sender=:1.3 -> dest=:1.10 reply_serial=2
   array [
      dict entry(
         string "Name"
         variant             string "WiFi"
      )
      dict entry(
         string "Type"
         variant             string "wifi"
      )
      dict entry(
         string "Powered"
         variant             boolean true
      )
      dict entry(
         string "Connected"
         variant             boolean true
      )
      dict entry(
         string "Tethering"
         variant             boolean false
      )
   ]

Also tried on the 2.x line, which needs some NetworkManager magic:

Put together from the NetworkManager DBus reference and this blogpost: Dbus Tutorial - Fun with Network Manager, it should work with something like:

DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
dbus-send \
 --system \
 --print-reply \
 --dest=org.freedesktop.NetworkManager \
 /org/freedesktop/NetworkManager \
 org.freedesktop.DBus.Properties.GetAll \
 string:"org.freedesktop.NetworkManager"

and look for the State variable, or call it directly with

DBUS_SYSTEM_BUS_ADDRESS=unix:path=/host/run/dbus/system_bus_socket \
dbus-send \
 --system \
 --print-reply \
 --dest=org.freedesktop.NetworkManager \
 /org/freedesktop/NetworkManager \
 org.freedesktop.DBus.Properties.Get \
 string:"org.freedesktop.NetworkManager" \
 string:"State"

State can take these values, and value 70 meaning global connectivity.

NetworkManager should have a lot more tricks up its sleeve, so would love to hear what you make in the end!

There’s also some notes in this other forum post how to use Node.js with DBus for networking, and there’s of course binding in a bunch of other languages to make it easier to tie it in.