Skip to content

Commit

Permalink
Add support to setup Tachyon
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Jan 24, 2025
1 parent be7cbd4 commit 21c3919
Show file tree
Hide file tree
Showing 11 changed files with 415 additions and 5 deletions.
Binary file modified assets/qdl/darwin/arm64/qdl
Binary file not shown.
Binary file modified assets/qdl/darwin/x64/qdl
Binary file not shown.
Binary file modified assets/qdl/linux/arm64/qdl
Binary file not shown.
Binary file modified assets/qdl/linux/x64/qdl
Binary file not shown.
Binary file modified assets/qdl/win32/x64/qdl.exe
Binary file not shown.
2 changes: 2 additions & 0 deletions src/cli/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -28,6 +28,7 @@ const webhook = require('./webhook');
const whoami = require('./whoami');
const wifi = require('./wifi');
const usb = require('./usb');
const setup = require('./setup');

/**
* The default function export from this module registers all the available commands.
Expand Down Expand Up @@ -75,4 +76,5 @@ module.exports = function registerAllCommands(context) {
wifi(context);
usb(context);
alias(context);
setup(context);
};
16 changes: 16 additions & 0 deletions src/cli/setup.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
module.exports = ({ commandProcessor, root }) => {
const setup = commandProcessor.createCategory(root, 'setup', 'Setup Particle devices');

commandProcessor.createCommand(setup, 'tachyon', 'Setup a Tachyon device', {
handler: () => {
const SetupCommands = require('../cmd/setup');
return new SetupCommands().setupTachyon();
},
examples: {
'$0 $command': 'Setup a Tachyon device'
}
});

return setup;
};

2 changes: 1 addition & 1 deletion src/cli/wifi.js
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
const unindent = require('../lib/unindent');

module.exports = ({ commandProcessor, root }) => {
const wifi = commandProcessor.createCategory(root, 'wifi', 'Configure Wi-Fi credentials to your device (Supported on Gen 3+ devices).');
const wifi = commandProcessor.createCategory(root, 'wifi', 'Configure Wi-Fi credentials to your device (Supported on Gen 3+ devices)');

commandProcessor.createCommand(wifi, 'add', 'Adds a Wi-Fi network to your device', {
options: Object.assign({
Expand Down
37 changes: 37 additions & 0 deletions src/cmd/api.js
Original file line number Diff line number Diff line change
Expand Up @@ -232,6 +232,43 @@ module.exports = class ParticleApi {
);
}

getOrgs() {
return this._wrap(
this.api.get({
uri: '/v1/orgs',
auth: this.accessToken
})
);
}

getRegistrationCode(productId) {
return this._wrap(
this.api.post({
uri: `/v1/products/${productId}/registration_code`,
auth: this.accessToken
})
);
}

createProduct({ name, type, org }) {
return this._wrap(
this.api.post({
uri: `/v1${org ? `/orgs/${org}` : ''}/products`,
form: { name, type },
auth: this.accessToken
})
);
}

getProducts(org) {
return this._wrap(
this.api.get({
uri: `/v1${org ? `/orgs/${org}` : ''}/products`,
auth: this.accessToken
})
);
}

getDevice({ deviceId: id }) {
return this.api.getDevice({ deviceId: id, auth: this.accessToken });
}
Expand Down
5 changes: 1 addition & 4 deletions src/cmd/flash.js
Original file line number Diff line number Diff line change
Expand Up @@ -71,8 +71,6 @@ module.exports = class FlashCommand extends CLICommandBase {
}

async flashTachyon({ files, output }) {
this.ui.write(`${os.EOL}Ensure that only one device is connected to the computer before proceeding.${os.EOL}`);

let zipFile;
let includeDir = '';
let updateFolder = '';
Expand Down Expand Up @@ -101,13 +99,12 @@ module.exports = class FlashCommand extends CLICommandBase {
filesToProgram = files;
}

this.ui.write(`Starting download. This may take several minutes...${os.EOL}`);
if (output && !fs.existsSync(output)) {
fs.mkdirSync(output);
}
const outputLog = path.join(output ? output : process.cwd(), `tachyon_flash_${Date.now()}.log`);
try {
this.ui.write(`Logs are being written to: ${outputLog}${os.EOL}`);
this.ui.write(`Starting download. This may take several minutes. See logs at: ${outputLog}${os.EOL}`);
const qdl = new QdlFlasher({
files: filesToProgram,
includeDir,
Expand Down
Loading

0 comments on commit 21c3919

Please sign in to comment.