diff --git a/tests/suites/os/suite.js b/tests/suites/os/suite.js index a23105c932..825bb68096 100644 --- a/tests/suites/os/suite.js +++ b/tests/suites/os/suite.js @@ -34,6 +34,14 @@ const supportsBootConfig = (deviceType) => { ); }; +const externalAnt = (deviceType) => { + return ( + [ + 'revpi-connect-4' + ] + ).includes(deviceType) +} + const flasherConfig = (deviceType) => { return ( [ @@ -69,6 +77,30 @@ const enableSerialConsole = async (imagePath) => { } }; +// For use with device types (e.g revpi connect 4) where an external antenna needs to be configured throuhg config.txt to work +const enableExternalAntenna = async (imagePath) => { + const bootConfig = await imagefs.interact(imagePath, 1, async (_fs) => { + return util + .promisify(_fs.readFile)('/config.txt') + .catch((err) => { + return undefined; + }); + }); + + if (bootConfig) { + await imagefs.interact(imagePath, 1, async (_fs) => { + const value = 'dtparam=ant2'; + + console.log(`Setting ${value} in config.txt...`); + + await util.promisify(_fs.writeFile)( + '/config.txt', + bootConfig.toString().concat(`\n\n${value}\n\n`), + ); + }); + } +}; + // For device types that support it, this enables skipping boot switch selection, to simplify the automated flashing const setFlasher = async(imagePath) => { await imagefs.interact(imagePath, 1, async (_fs) => { @@ -317,6 +349,10 @@ module.exports = { await setFlasher(this.os.image.path); } + if(externalAnt(this.suite.deviceType.slug)){ + await enableExternalAntenna(this.os.image.path); + } + if (this.suite.options?.balena?.apiKey) { // Authenticating balenaSDK await this.context