Hierarchy

Constructors

Properties

characteristic: BleRemoteCharacteristic
onread?: ((data) => void)

Type declaration

    • (data): void
    • Callback function when read value.

      Parameters

      • data: any

      Returns void

onwrite?: ((result) => void)

Type declaration

    • (result): void
    • Callback function when write value finished.

      Parameters

      • result: any

      Returns void

uuid: string

It is uuid as string.

console.log(attr.uuid); // => '4C84'

Methods

  • Read data from descriptor.

    The return value appears in the callback function [[onread]]. If reading succeeds an Array with data will be returned. It throws an error when failed.

    // Javascript Example
    await obniz.ble.initWait();
    var target = {
    uuids: ["fff0"],
    };
    var peripheral = await obniz.ble.scan.startOneWait(target);
    if(peripheral){
    await peripheral.connectWait();
    console.log("connected");
    await obniz.wait(1000);

    var dataArray = await peripheral.getService("FF00").getCharacteristic("FF01").readWait();
    console.log(dataArray);
    }

    Returns Promise<number[]>

  • This writes dataArray to descriptor. It throws an error when failed.

    // Javascript Example

    await obniz.ble.initWait();
    var target = {
    uuids: ["fff0"],
    };
    var peripheral = await obniz.ble.scan.startOneWait(target);
    if(peripheral){
    await peripheral.connectWait();
    console.log("connected");
    await obniz.wait(1000);

    var dataArray = [0x02, 0xFF];
    await peripheral.getService("FF00").getCharacteristic("FF01").getDescriptor("2901").writeWait(dataArray);
    console.log("write success");
    }

    Parameters

    • data: number[]

    Returns Promise<boolean>

Generated using TypeDoc