diff --git a/lib/config.js b/lib/config.js index 910d8ff..d0bd1ea 100644 --- a/lib/config.js +++ b/lib/config.js @@ -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: '' } }); @@ -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. @@ -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 @@ -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) { diff --git a/lib/device.js b/lib/device.js index a814e28..de261d4 100644 --- a/lib/device.js +++ b/lib/device.js @@ -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); }