particle-iot / particle-cli

Command Line Interface for Particle Cloud and devices
Apache License 2.0
212 stars 92 forks source link

Improve Wi-Fi Setup Experience #742

Closed keeramis closed 4 months ago

keeramis commented 5 months ago

Description

This PR introduces the new particle wifi xxx commands.

particle wifi add

particle wifi join

particle wifi list, particle wifi clear, particle wifi remove, particle wifi current

In all the above cases, if a particular command is not supported on a given firmware version, a relevant error is returned.

How to Test

Run npm install which will have the latest necessary changes

Test away a wifi or non-wifi device

For the particle wifi add to work, use the latest device-os develop branch https://github.com/particle-iot/device-os/commits/develop/

Related Issues / Discussions

Completeness

keeramis commented 5 months ago

Hi @monkbroc @hugomontero! I updated this PR to have the necessary functionality in place. I added the right errors and briefly tested some scenarios with Hugo. If you could kindly test this, that'd be great for initial feedback. I am working on unit tests and e2e tests.

keeramis commented 4 months ago

This PR is ready for review @monkbroc @hugomontero 🙇

The tests fail with a Test file busy error as if the build was not found for ubuntu-latest

monkbroc commented 4 months ago

I didn't get an error on wifi add on an Argon on 5.8.1

$ particle.js wifi add
? Would you like to scan for Wi-Fi networks? Yes
? Select the Wi-Fi network with which you wish to connect your device: bunker
? Wi-Fi Password xyz
Wi-Fi network 'bunker' added successfully.
To join this network, run particle wifi join --ssid <SSID>

monkbroc@beast:~/Programming/cli$ particle.js identify
Your device id is e00fce68a97a9afad515ab96
Your system firmware version is 5.8.1
keeramis commented 4 months ago

@monkbroc May you have a 5.8.1 based develop branch that has this control request working? CLI looks for Not supported error from the device-os.

I quickly tested on mine:

keerthyamisagadda@loaners-macbook-pro particle-cli (feature/wifi-improvements) $ npm start -- wifi add --file creds.json 

> particle-cli@3.23.6 start
> node ./src/index.js wifi add --file creds.json

Unable to add Wi-Fi network 'D49-10': Not supported
This feature is likely not supported on this firmware version.
Update to device-os 6.2.0 or use 'particle wifi join --help' to join a network.
Alternatively, check 'particle serial wifi'.

keerthyamisagadda@loaners-macbook-pro particle-cli (feature/wifi-improvements) $ npm start -- serial identify

> particle-cli@3.23.6 start
> node ./src/index.js serial identify

Your device id is e00fce6819ef5f971ea9563a
Your system firmware version is 5.8.0
monkbroc commented 4 months ago

Indeed. I reflashed with 5.8.1 from the cloud and get the expected error :+1:

keeramis commented 4 months ago

I am merging this PR unless I hear otherwise