Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

add support for --network option to force usage of a specific network interface #33

Merged
merged 1 commit into from
Jan 27, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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
Loading