Skip to content

Commit

Permalink
Merge pull request #33 from particle-iot/feature/network-option
Browse files Browse the repository at this point in the history
add support for --network option to force usage of a specific network interface
  • Loading branch information
avtolstoy authored Jan 27, 2025
2 parents 2b10a87 + f40360a commit b1f6eeb
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 1 deletion.
16 changes: 15 additions & 1 deletion lib/config.js
Original file line number Diff line number Diff line change
Expand Up @@ -220,6 +220,11 @@ const config = convict({
doc: 'Do not flash firmware binaries',
format: Boolean,
default: false
},
network :{
doc: 'Force use of a specific network interface',
format: String,
default: ''
}
});

Expand Down Expand Up @@ -278,6 +283,9 @@ Options:
--dry
Verify the configuration and skip all tests.
--network=NETWORK
Force usage of a specific network interface ("wifi", "ethernet", "cellular")
-v, --verbose
Enable verbose logging.
Expand Down Expand Up @@ -326,7 +334,7 @@ function loadCliProfile() {
// TODO: Describe command-specific arguments separately
function parseCmdLine() {
return parseArgs(process.argv.slice(2), {
string: ['_', 'grep', 'config-file', 'test-dir', 'binary-dir', 'device-os-dir', 'target-dir', 'report-file'],
string: ['_', 'grep', 'config-file', 'test-dir', 'binary-dir', 'device-os-dir', 'target-dir', 'report-file', 'network'],
boolean: ['build', 'dry', 'fixtures', 'tags', 'combine', 'version', 'help', 'json', 'verbose', 'flash'],
default: {
'flash': true
Expand Down Expand Up @@ -464,6 +472,12 @@ function updateConfig(args) {
}
// Whether to build and flash firmware binaries
config.set('noFlash', !args['flash']);

// Forces usage of a specific network
const network = args['network'];
if (network) {
config.set('network', network);
}
}

function loadConfigFiles(args) {
Expand Down
7 changes: 7 additions & 0 deletions lib/device.js
Original file line number Diff line number Diff line change
Expand Up @@ -101,6 +101,13 @@ class Device extends EventEmitter {
if (param.clearBackupMemory) {
req.b = 1;
}
if (config.get('network')) {
switch (config.get('network')) {
case 'wifi': req.n = 'w'; break;
case 'ethernet': req.n = 'e'; break;
case 'cellular': req.n = 'c'; break;
}
}
await this._request(req);
}

Expand Down

0 comments on commit b1f6eeb

Please sign in to comment.