opper
    Preparing search index...

    opper

    opper-js-sdk

    Opper SDK for JavaScript/TypeScript.

    CI License CodeFactor

    Package Intro Version
    @opper/core Opper core version
    @opper/wx WeChat adapter version
    @opper/capacitor Capacitor adapter version

      ☝️ Click the links above to view the README for each package.

    Choose the Opper adapter that's right for your needs.

    npm install @opper/core
    # If you're developing a WeChat app
    npm install @opper/wx
    # If you're developing a Capacitor app
    npm install @opper/capacitor

    If you're developing a Uni-app, or Taro app, we don't currently provide an official adapter package. But you can refer to @opper/wx for your own implementation, and feel free to contribute PR :)

    For the full API definition, please visit https://opper-devkit.github.io/opper-js-sdk.

    import { isOpperDevice, Opper } from '@opper/core';
    import { BluetoothLowEnergeDevice, BluetoothService } from '@opper/wx';
    import { finalize, map, switchMap } from 'rxjs';

    const bluetoothService = new BluetoothService();

    // Search for low-power Bluetooth devices
    bluetoothService.openAdapter().pipe(
    switchMap(() =>
    bluetoothService.startDevicesDiscovery({
    allowDuplicatesKey: true
    })
    ),
    switchMap(() => bluetoothService.devicesChange),
    map(devices => devices.filter(device => isOpperDevice(device))),
    finalize(() => {
    bluetoothService.stopDevicesDiscovery().subscribe();
    })
    ).subscribe(devices => {
    // Self-collection of searched equipment
    });

    // Create an Opper instance
    const opper = new Opper();
    // Create a BLE device
    const device = new BluetoothLowEnergeDevice('deviceId');
    // Connect to the device
    opper.connect(device).subscribe();

    // Subscribe to weight changes
    opper.weightChange.subscribe(weight => {
    console.log(`New weight: ${weight}`);
    });
    // Subscribe to battery level and status changes
    opper.batteryChange.subscribe(([battery, status]) => {
    console.log(`New battery level: ${battery}, Status: ${status}`);
    });
    // ...