How to use @ledgerhq/hw-transport-node-ble - 4 common examples

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;
  };
github LedgerHQ / ledger-live-common / cli / src / live-common-setup.js View on Github external
disconnect: query =>
      query.startsWith("ble")
        ? cacheBle[query]
          ? TransportNodeBle.disconnect(cacheBle[query].id)
          : Promise.resolve()
        : null
  });
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;
  };
  registerTransportModule({
github LedgerHQ / ledger-live-common / cli / src / live-common-setup.js View on Github external
            switchMap(e => TransportNodeBle.open(e.descriptor))
          )

@ledgerhq/hw-transport-node-ble

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

MIT
Latest version published 9 months ago

Package Health Score

78 / 100
Full package analysis