How to use the @ledgerhq/hw-transport-node-ble.default.create function in @ledgerhq/hw-transport-node-ble

To help you get started, we’ve selected a few @ledgerhq/hw-transport-node-ble examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github LedgerHQ / ledger-live-common / cli / src / live-common-setup.js View on Github external
const openBleByQuery = async query => {
    const m = query.match(/^ble:?(.*)/);
    if (!m) throw new Error("ble regexp should match");
    const [, q] = m;
    if (cacheBle[query]) return cacheBle[query];
    const t = await (!q
      ? TransportNodeBle.create()
      : Observable.create(TransportNodeBle.listen)
          .pipe(
            first(
              e =>
                (e.device.name || "").toLowerCase().includes(q.toLowerCase()) ||
                e.device.id.toLowerCase() === q.toLowerCase()
            ),
            switchMap(e => TransportNodeBle.open(e.descriptor))
          )
          .toPromise());
    cacheBle[query] = t;
    t.on("disconnect", () => {
      delete cacheBle[query];
    });
    return t;
  };

@ledgerhq/hw-transport-node-ble

Ledger Hardware Wallet Bluetooth BLE transport for Node.js (noble)

MIT
Latest version published 8 months ago

Package Health Score

78 / 100
Full package analysis