Skip to content

Commit

Permalink
Add binary option
Browse files Browse the repository at this point in the history
  • Loading branch information
keeramis committed Nov 26, 2024
1 parent 1635395 commit fde02e9
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 4 deletions.
9 changes: 8 additions & 1 deletion ESIM_PROVISION.md
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,13 @@
Put your files in this structure (for example)

```
/kigen-resources
├── /binaries
│ ├── esim-firmware-b5som.bin
│ ├── esim-firmware-msom.bin
├── input.json
├── output.json
├── lpa
```

### Device Setup
Expand All @@ -29,3 +35,4 @@ particle.js esim provision --input /path/to/input.json --output /path/to/output.
First, the device(s) are flashed. Once the download process starts on a given device, device will turn its LED into yellow. If the download passes, LED turns green. If the download failed, LED turns red.

### Notes and Warnings
1.
3 changes: 3 additions & 0 deletions src/cli/esim.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,9 @@ module.exports = ({ commandProcessor, root }) => {
},
'output': {
description: 'Provide the output json file path'
},
'binary': {
description: 'Provide the path to the binaries'
},
'bulk': {
description: 'Provision multiple devices'
Expand Down
10 changes: 7 additions & 3 deletions src/cmd/esim.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@ const path = require('path');
const _ = require('lodash');

// TODO: Get these from exports
const PATH_TO_PASS_THROUGH_BINARIES = '/Users/keerthyamisagadda/code/kigen-resources/binaries';
const PROVISIONING_PROGRESS = 1;
const PROVISIONING_SUCCESS = 2;
const PROVISIONING_FAILURE = 3;
Expand All @@ -30,6 +29,7 @@ module.exports = class eSimCommands extends CLICommandBase {
this.inputJsonData = null;
this.outputJson = null;
this.downloadedProfiles = [];
this.binaries = null;
this.verbose = false;
}

Expand Down Expand Up @@ -277,12 +277,16 @@ module.exports = class eSimCommands extends CLICommandBase {
if (!args.lpa) {
throw new Error('Missing input LPA tool path');
}
if (!args.binary) {
throw new Error('Missing folder path to binaries');
}
this.inputJson = args.input;
const input = fs.readFileSync(this.inputJson);
this.inputJsonData = JSON.parse(input);

this.outputJson = args.output;
this.lpa = args.lpa;
this.binaries = args.binary;
}

async _flashATPassThroughFirmware(device, platform) {
Expand All @@ -300,15 +304,15 @@ module.exports = class eSimCommands extends CLICommandBase {
try {
// Locate the firmware binary
logAndPush(`${os.EOL}Locating firmware for platform: ${platform}`);
const fwBinaries = fs.readdirSync(PATH_TO_PASS_THROUGH_BINARIES);
const fwBinaries = fs.readdirSync(this.binaries);
const validBin = fwBinaries.find((file) => file.endsWith(`${platform}.bin`));

if (!validBin) {
logAndPush(`No firmware binary found for platform: ${platform}`);
return { success: false, output: outputLogs };
}

const fwPath = path.join(PATH_TO_PASS_THROUGH_BINARIES, validBin);
const fwPath = path.join(this.binaries, validBin);
logAndPush(`${os.EOL}Found firmware: ${fwPath}`);

// Flash the binary
Expand Down

0 comments on commit fde02e9

Please sign in to comment.