Skip to content

Commit

Permalink
tests: os: use secondary antenna for revpi4
Browse files Browse the repository at this point in the history
Change-type: patch
Signed-off-by: Ryan Cooke <ryan@balena.io>
  • Loading branch information
rcooke-warwick committed Feb 27, 2024
1 parent 53ff24d commit 67f34c9
Showing 1 changed file with 36 additions and 0 deletions.
36 changes: 36 additions & 0 deletions tests/suites/os/suite.js
Expand Up @@ -34,6 +34,14 @@ const supportsBootConfig = (deviceType) => {
);
};

const externalAnt = (deviceType) => {
return (
[
'revpi-connect-4'
]
).includes(deviceType)
}

const flasherConfig = (deviceType) => {
return (
[
Expand Down Expand Up @@ -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) => {
Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 67f34c9

Please sign in to comment.