How to use the @ledgerhq/devices/lib/ble/sendAPDU.sendAPDU function in @ledgerhq/devices

To help you get started, weā€™ve selected a few @ledgerhq/devices 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 / ledgerjs / packages / hw-transport-web-ble / src / TransportWebBLE.js View on Github external
this.exchangeAtomicImpl(async () => {
      try {
        const msgIn = apdu.toString("hex");
        log("apdu", `=> ${msgIn}`);

        const data = await merge(
          this.notifyObservable.pipe(receiveAPDU),
          sendAPDU(this.write, apdu, this.mtuSize)
        ).toPromise();

        const msgOut = data.toString("hex");
        log("apdu", `<= ${msgOut}`);

        return data;
      } catch (e) {
        log("ble-error", "exchange got " + String(e));
        if (this.notYetDisconnected) {
          // in such case we will always disconnect because something is bad.
          this.device.gatt.disconnect();
        }
        throw e;
      }
    });
github LedgerHQ / ledgerjs / packages / react-native-hw-transport-ble / src / BleTransport.js View on Github external
this.exchangeAtomicImpl(async () => {
      try {
        const msgIn = apdu.toString("hex");
        log("apdu", `=> ${msgIn}`);

        const data = await merge(
          this.notifyObservable.pipe(receiveAPDU),
          sendAPDU(this.write, apdu, this.mtuSize)
        ).toPromise();

        const msgOut = data.toString("hex");
        log("apdu", `<= ${msgOut}`);

        return data;
      } catch (e) {
        log("ble-error", "exchange got " + String(e));
        if (this.notYetDisconnected) {
          // in such case we will always disconnect because something is bad.
          await bleManager.cancelDeviceConnection(this.id).catch(() => {}); // but we ignore if disconnect worked.
        }
        throw remapError(e);
      }
    });
github LedgerHQ / ledgerjs / packages / hw-transport-node-ble / src / TransportNodeBle.js View on Github external
this.exchangeAtomicImpl(async () => {
      try {
        const msgIn = apdu.toString("hex");
        log("apdu", `=> ${msgIn}`);

        const data = await merge(
          this.notifyObservable.pipe(receiveAPDU),
          sendAPDU(this.write, apdu, this.mtuSize)
        ).toPromise();

        const msgOut = data.toString("hex");
        log("apdu", `<= ${msgOut}`);

        return data;
      } catch (e) {
        log("ble-error", "exchange got " + String(e));
        if (this.notYetDisconnected) {
          // in such case we will always disconnect because something is bad.
          await disconnectDevice(this.device).catch(() => {}); // but we ignore if disconnect worked.
        }
        throw e;
      }
    });