Skip to content

Commit

Permalink
minor cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Jun 3, 2024
1 parent 0f039be commit 508a691
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 24 deletions.
24 changes: 13 additions & 11 deletions src/cli/wifi.js
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ const unindent = require('../lib/unindent');
module.exports = ({ commandProcessor, root }) => {
const wifi = commandProcessor.createCategory(root, 'wifi', 'Configure Wi-Fi credentials to your device (Supported on Gen 3+ devices).');

commandProcessor.createCommand(wifi, 'add', 'Adds a WiFi network to your device', {
commandProcessor.createCommand(wifi, 'add', 'Adds a Wi-Fi network to your device', {
options: Object.assign({
'file': {
description: 'Take the credentials from a JSON file instead of prompting for them'
Expand All @@ -22,15 +22,16 @@ module.exports = ({ commandProcessor, root }) => {
{
"network": "my_ssid",
"security": "WPA2_PSK",
"password": "my_password"
"password": "my_password",
"hidden": false
}
The security property can be NONE, WEP, WPA_PSK, WPA2_PSK, WPA3_PSK, WPA_WPA2_PSK, WPA2_WPA3_PSK.
The security property can be NONE, WEP, WPA_PSK, WPA2_PSK, WPA3_PSK.
Enterprise networks are not supported.
`)
});

commandProcessor.createCommand(wifi, 'join', 'Joins a wifi network', {
commandProcessor.createCommand(wifi, 'join', 'Joins a Wi-Fi network', {
options: Object.assign({
'file': {
description: 'Take the credentials from a JSON file instead of prompting for them'
Expand All @@ -56,10 +57,11 @@ module.exports = ({ commandProcessor, root }) => {
{
"network": "my_ssid",
"security": "WPA2_PSK",
"password": "my_password"
"password": "my_password",
"hidden": false
}
The security property can be NONE, WEP, WPA_PSK, WPA2_PSK, WPA3_PSK, WPA_WPA2_PSK, WPA2_WPA3_PSK.
The security property can be NONE, WEP, WPA_PSK, WPA2_PSK, WPA3_PSK.
Enterprise networks are not supported.
`)
});
Expand All @@ -74,7 +76,7 @@ module.exports = ({ commandProcessor, root }) => {
}
});

commandProcessor.createCommand(wifi, 'list', 'Lists the wifi networks on your device', {
commandProcessor.createCommand(wifi, 'list', 'Lists the Wi-Fi networks on your device', {
handler: () => {
const WiFiCommands = require('../cmd/wifi');
return new WiFiCommands().listNetworks();
Expand All @@ -84,7 +86,7 @@ module.exports = ({ commandProcessor, root }) => {
}
});

commandProcessor.createCommand(wifi, 'remove', 'Removes a wifi network from the device', {
commandProcessor.createCommand(wifi, 'remove', 'Removes a Wi-Fi network from the device', {
options: Object.assign({
'ssid': {
description: 'The name of the network to remove'
Expand All @@ -99,16 +101,16 @@ module.exports = ({ commandProcessor, root }) => {
}
});

commandProcessor.createCommand(wifi, 'current', 'Gets the current wifi network', {
commandProcessor.createCommand(wifi, 'current', 'Gets the current Wi-Fi network', {
handler: () => {
const WiFiCommands = require('../cmd/wifi');
return new WiFiCommands().getCurrentNetwork();
},
examples: {
'$0 $command ssid': 'Gets the wifi network that the device is currently connected to',
'$0 $command ssid': 'Gets the Wi-Fi network that the device is currently connected to',
}
});

return wifi;
};

3 changes: 1 addition & 2 deletions src/cmd/serial.js
Original file line number Diff line number Diff line change
Expand Up @@ -260,7 +260,6 @@ module.exports = class SerialCommand extends CLICommandBase {

// Obtain system firmware version
fwVer = device.firmwareVersion;


// If the device is a cellular device, obtain imei and iccid

Expand Down Expand Up @@ -541,7 +540,7 @@ module.exports = class SerialCommand extends CLICommandBase {
this.ui.stdout.write(`${os.EOL}`);
}

// configure serial
// configure Wi-Fi via serial interface
if (file){
return this._configWifiFromFile(deviceFromSerialPort, file);
} else {
Expand Down
4 changes: 1 addition & 3 deletions src/cmd/wifi.js
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,6 @@ const securityMapping = {
'WPA2_WPA3_PSK': 'WPA2_WPA3_PSK',
};

// TODO: Add this to the help
const WifiSecurityConsolidatedForUserPrompt = ['NO_SECURITY', 'WEP', 'WPA_PSK', 'WPA2_PSK', 'WPA3_PSK'];

module.exports = class WiFiCommands extends CLICommandBase {
Expand Down Expand Up @@ -219,7 +218,6 @@ module.exports = class WiFiCommands extends CLICommandBase {
}

async _deviceScanNetworks() {
// undefined is returned if the device is reset etccc?
this.newSpin('Scanning for Wi-Fi networks').start();
let attempts = NUM_TRIES;
let lastError = null;
Expand Down Expand Up @@ -360,7 +358,7 @@ module.exports = class WiFiCommands extends CLICommandBase {
}
}

this.ui.stdout.write(`Wi-Fi network '${ssid}' configured successfully. Attemping to join...${os.EOL}Use 'particle wifi current' to check the current network.${os.EOL}`);
this.ui.stdout.write(`Wi-Fi network '${ssid}' configured successfully. Attemping to join...${os.EOL}Use ${chalk.yellow('particle wifi current')} to check the current network.${os.EOL}`);
}

async clearWifi() {
Expand Down
1 change: 1 addition & 0 deletions src/lib/device-error-handler.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ const deviceControlError = {
'LIBUSB_ERROR_OTHER': 'Other error',
};


module.exports = {
deviceControlError
};
2 changes: 1 addition & 1 deletion test/e2e/device.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ const {
} = require('../lib/env');


describe('Device Commands [@device]', () => { // [@device,wifi]???
describe('Device Commands [@device]', () => {
const help = [
'Manipulate a device',
'Usage: particle device <command>',
Expand Down
14 changes: 7 additions & 7 deletions test/e2e/wifi.e2e.js
Original file line number Diff line number Diff line change
Expand Up @@ -14,12 +14,12 @@ describe('Wi-Fi Commands [@device,@wifi]', () => {
'Help: particle help wifi <command>',
'',
'Commands:',
' add Adds a WiFi network to your device',
' join Joins a wifi network',
' clear Clears the list of wifi networks on your device',
' list Lists the wifi networks on your device',
' remove Removes a wifi network from the device',
' current Gets the current wifi network',
' add Adds a Wi-Fi network to your device',
' join Joins a Wi-Fi network',
' clear Clears the list of Wi-Fi networks on your device',
' list Lists the Wi-Fi networks on your device',
' remove Removes a Wi-Fi network from the device',
' current Gets the current Wi-Fi network',
'',
'Global Options:',
' -v, --verbose Increases how much logging to display [count]',
Expand Down Expand Up @@ -78,7 +78,7 @@ describe('Wi-Fi Commands [@device,@wifi]', () => {
const { stdout, stderr, exitCode } = await cli.run(['wifi', 'join', '--ssid', WIFI_SSID]);

expect(listStdout).to.include(WIFI_SSID);
expect(stdout).to.include(`Wi-Fi network '${WIFI_SSID}' configured successfully. Attemping to join...\nUse \'particle wifi current\' to check the current network.`);
expect(stdout).to.include(`Wi-Fi network '${WIFI_SSID}' configured successfully. Attemping to join...\nUse particle wifi current to check the current network.`);
expect(stderr).to.equal('');
expect(exitCode).to.equal(0);
});
Expand Down

0 comments on commit 508a691

Please sign in to comment.