How to use the @ledgerhq/devices.getInfosForServiceUuid 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 / react-native-hw-transport-ble / src / BleTransport.js View on Github external
await device.connect();
      } else {
        throw e;
      }
    }
  }

  await device.discoverAllServicesAndCharacteristics();

  let res = retrieveInfos(device);
  let characteristics;
  if (!res) {
    for (const uuid of getBluetoothServiceUuids()) {
      try {
        characteristics = await device.characteristicsForService(uuid);
        res = getInfosForServiceUuid(uuid);
        break;
      } catch (e) {
        // we attempt to connect to service
      }
    }
  }
  if (!res) {
    throw new TransportError("service not found", "BLEServiceNotFound");
  }

  const { deviceModel, serviceUuid, writeUuid, notifyUuid } = res;

  if (!characteristics) {
    characteristics = await device.characteristicsForService(serviceUuid);
  }
github LedgerHQ / ledgerjs / packages / hw-transport-web-ble / src / TransportWebBLE.js View on Github external
const retrieveService = async device => {
  if (!device.gatt) throw new Error("bluetooth gatt not found");
  const [service] = await device.gatt.getPrimaryServices();
  if (!service) throw new Error("bluetooth service not found");
  const infos = getInfosForServiceUuid(service.uuid);
  if (!infos) throw new Error("bluetooth service infos not found");
  return [service, infos];
};
github LedgerHQ / ledgerjs / packages / react-native-hw-transport-ble / src / BleTransport.js View on Github external
const retrieveInfos = device => {
  if (!device || !device.serviceUUIDs) return;
  const [serviceUUID] = device.serviceUUIDs;
  if (!serviceUUID) return;
  const infos = getInfosForServiceUuid(serviceUUID);
  if (!infos) return;
  return infos;
};
github LedgerHQ / ledger-live-desktop / src / hw-transport-node-ble / src / TransportNodeBLE.js View on Github external
const retrieveService = async device => {
  if (!device.gatt) throw new Error('bluetooth gatt not found')
  const [service] = await device.gatt.getPrimaryServices()
  if (!service) throw new Error('bluetooth service not found')
  const infos = getInfosForServiceUuid(service.uuid)
  if (!infos) throw new Error('bluetooth service infos not found')
  return [service, infos]
}
github LedgerHQ / ledgerjs / packages / hw-transport-node-ble / src / platform.js View on Github external
export const retrieveServiceAndCharacteristics = async (device: *) => {
  const [service] = await discoverDeviceServices(device);
  const infos = getInfosForServiceUuid(service.uuid);
  if (!infos) {
    throw new TransportError("service not found", "BLEServiceNotFound");
  }
  const characteristics = await discoverServiceCharacteristics(service);
  let writeC;
  let notifyC;
  for (const c of characteristics) {
    if (c.uuid === infos.writeUuid.replace(/-/g, "")) {
      writeC = c;
    } else if (c.uuid === infos.notifyUuid.replace(/-/g, "")) {
      notifyC = c;
    }
  }
  if (!writeC || !notifyC) {
    throw new TransportError(
      "missing characteristics",