Hierarchy

Constructors

  • Create Characteristics

    await obniz.ble.initWait();
    var characteristic = new obniz.ble.characteristic({
    "uuid" : "FFF1",
    "properties" : ["read","write"], // read, write, notify
    "data" : [0x0e, 0x00, ...], //data for dataArray or text for string
    "descriptors" : [{
    "uuid" : "2901", //Characteristic User Description
    "text" : "hello world characteristic", //data for dataArray or text for string
    }]
    });

    var service = new obniz.ble.service({
    "uuid" : "fff0",
    "characteristics" : [ characteristic ]
    });
    obniz.ble.peripheral.addService(service);

    Parameters

    Returns BleCharacteristic

Properties

onreadfromremote?: ((address) => void)

Type declaration

    • (address): void
    • This is a callback function used when characteristic is read by an external device.

      characteristic.onreadfromremote = function(address){
      console.log("remote address :",address);
      }

      Parameters

      • address: string

      Returns void

onwritefromremote?: ((address, data) => void)

Type declaration

    • (address, data): void
    • This is a callback function used when characteristic is read by an external device.

      characteristic.onwritefromremote = function(address, newvalue){
      console.log("remote address :",address);
      console.log("remote data :",newvalue);
      }

      Parameters

      • address: string
      • data: number[]

      Returns void

service: BleService

Service instance

uuid: string

It is uuid as string.

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

Accessors

Methods

  • This sends notify to the connected central.

    var characteristic = new obniz.ble.characteristic({
    uuid: 'FFF1',
    data: [0x0e, 0x00],
    properties : ["read","write","notify"], // add notify properties
    });

    var service = new obniz.ble.service({
    uuid: 'FFF0',
    characteristics: [characteristic],
    });
    obniz.ble.peripheral.addService(service);


    // after central connected
    characteristic.notify();

    Returns void

Generated using TypeDoc