How to use the react-native-ble-plx.BleErrorCode.DeviceMTUChangeFailed function in react-native-ble-plx

To help you get started, we’ve selected a few react-native-ble-plx examples, based on popular ways it is used in public projects.

github LedgerHQ / ledgerjs / packages / react-native-hw-transport-ble / src / BleTransport.js View on Github external
}
    }

    if (!device) {
      throw new CantOpenDevice();
    }
  } else {
    device = deviceOrId;
  }

  if (!(await device.isConnected())) {
    log("ble-verbose", "not connected. connecting...");
    try {
      await device.connect(connectOptions);
    } catch (e) {
      if (e.errorCode === BleErrorCode.DeviceMTUChangeFailed) {
        // eslint-disable-next-line require-atomic-updates
        connectOptions = {};
        await device.connect();
      } else {
        throw e;
      }
    }
  }

  await device.discoverAllServicesAndCharacteristics();

  let res = retrieveInfos(device);
  let characteristics;
  if (!res) {
    for (const uuid of getBluetoothServiceUuids()) {
      try {
github LedgerHQ / ledger-live-mobile / src / react-native-hw-transport-ble / BleTransport.js View on Github external
if (!device) {
        throw new CantOpenDevice();
      }
    } else {
      device = deviceOrId;
    }

    if (!(await device.isConnected())) {
      logSubject.next({
        type: "verbose",
        message: "not connected. connecting...",
      });
      try {
        await device.connect(connectOptions);
      } catch (e) {
        if (e.errorCode === BleErrorCode.DeviceMTUChangeFailed) {
          connectOptions = {};
          await device.connect();
        } else {
          throw e;
        }
      }
    }

    await device.discoverAllServicesAndCharacteristics();

    const characteristics = await device.characteristicsForService(ServiceUuid);
    if (!characteristics) {
      throw new TransportError("service not found", "BLEServiceNotFound");
    }
    let writeC;
    let notifyC;

react-native-ble-plx

React Native Bluetooth Low Energy library

Apache-2.0
Latest version published 11 months ago

Package Health Score

72 / 100
Full package analysis

Similar packages