Setup WiFI without cli wizard

Greetings,

I was a bit surprised that there is not a cli category. Anyway. I am working to setup WiFi on many Photons using the cli and particle serial wifi. My question: Is there a way to use this command, or one like it, to setup WiFi and not use the wizard, simply pass the needed parameters on the command line. I can write a script as suggested here though obviously would like to avoid it if there is a way to do it already baked in.

Thank you,

Brett Slaski

1 Like

Hi @brettski

Iā€™m trying to acheive the same thing.

Currently I am experimenting with the reliablity of echoing the wifi credentials directly to the device file and it is working well.

You can do this without CLI at all, just by placing the device in Listening Mode and send the w command followed by the respective settings.

I believe @brettski is looking for a scripted solution to set up many devices in succession like I am.

And how would that not be possible that way?

It is possible that way. Here is how I am using that interface to connect a photon to Wi-Fi:

setupWifi()
{
  if ls -1 /dev/cu.usbmodem* 1> /dev/null 2>&1; then
    MODEM=$(ls -1 /dev/cu.usbmodem*)
  else
    MODEM="NONE"
  fi

  if [[ "$MODEM" == "NONE" ]]; then
    echo "No device found" > /dev/null
    return
  fi

  echo "Please enter your Wi-Fi credentials..."
  read -rp "SSID: " SSID
  read -rp "Security 0=unsecured, 1=WEP, 2=WPA, 3=WPA2: " SECURITY

  if [[ "$SECURITY" != "0" ]]; then
    read -rp "Password: " PASSWORD
  fi

  echo -n "w" > "$MODEM"
  sleep 1.5

  echo "$SSID" >> "$MODEM"
  sleep 1.5

  echo "$SECURITY" >> "$MODEM" # 0=unsecured, 1=WEP, 2=WPA, 3=WPA2
  sleep 1.5

  if [[ "$SECURITY" != "0" ]]; then
    echo "$PASSWORD" >> "$MODEM"
  fi
}
2 Likes

Not exactly sure what you mean by w command. Is there a reference you can point to so I may read how I may interact with the Photon in listening mode?

Thank you

Here it is:

https://docs.particle.io/support/troubleshooting/troubleshooting-tools/photon/#listening-mode-commands

2 Likes