Detect the state of the wifi

Hello,
I would like to change the background depending on the state of the wifi :

if (//wifi is activated\\) {
   background(0,255,0);
 } else {
   background(255,0,0);
}

What should we put in place of “//wifi is activated\” ?
Do you have an idea to solve my problem ?
Thank you.

Whether your computer has wifi on or not is OS-level information. How to check will depend on if you are on Windows, MacOS, or Linux.

For example, on Windows, you could use command to check ipconfig or ping.

https://www.digitalcitizen.life/command-prompt-advanced-networking-commands

On MacOS, you could try a command to ping or netstat.

Or, if you have a particular server you are connecting to in your sketch, just test its availability directly with the network library using available().

https://processing.org/reference/libraries/net/Client_available_.html

2 Likes