-
Notifications
You must be signed in to change notification settings - Fork 332
LLC:gist firmware
elbywan edited this page Apr 26, 2022
·
1 revision
We start a new project and add live-common and some helpers
yarn add @ledgerhq/live-common
yarn add rxjs # for Observable
Now we need a concrete implementation of a Transport to use the ledger device with. In our example we're going to do a Node.js script that works with USB, so we're just going to install these:
yarn add @ledgerhq/hw-transport-node-hid-noevents
We're all set up, let's write a script that will perform a firmware update!
const { concat } = require("rxjs/operators");
const getDeviceInfo = require("@ledgerhq/live-common/lib/getDeviceInfo")
.default;
const manager = require("@ledgerhq/live-common/lib/manager").default;
const prepare = require("@ledgerhq/live-common/lib/hw/firmwareUpdate-prepare")
.default;
const main = require("@ledgerhq/live-common/lib/hw/firmwareUpdate-main")
.default;
const deviceId = ""; // in HID case
//////////////////////////////////
// live-common requires some setup. usually we put that in a live-common-setup.js
const { registerTransportModule } = require("@ledgerhq/live-common/lib/hw");
const TransportNodeHid = require("@ledgerhq/hw-transport-node-hid-noevents")
.default;
// configure which transport are available
registerTransportModule({
id: "hid",
open: devicePath => TransportNodeHid.open(devicePath),
disconnect: () => Promise.resolve()
});
/////////////////////////
async function updateLogic() {
const deviceInfo = await withDevice("")(t => getDeviceInfo(t));
const firmware = await manager.getLatestFirmwareForDevice(deviceInfo);
if (!firmware) return "up to date";
concat(prepare("", firmware), main("", firmware)).subscribe(e =>
console.log(e)
);
}
updateLogic();
- Ledger Live Desktop
- Ledger Live Mobile
-
Ledger Live Common
- Introduction
- Currency Models
- Currency Bridge
- Account
- Account Bridge
- apps
- appsCheckAllAppVersions
- ledger-live bot
- Canonical Ways to Investigate Bugs
- Coin Integration Introduction
- Countervalues
- Packages Duplicates
- Derivation
- Developing with CLI
- Developing
- Gist Firmware Update
- Gist Transaction
- Hardware Wallet Logic
- Socket
- Assorted tips
- Integration Tests
- Process
- Monorepository Migration Guide
- Issues, Workaround and Tricks
- Common CI Troubleshooting
- Create staging builds using the CI
- Deprecated