Hierarchy

  • BlePeripheral

Constructors

Properties

currentConnectedDeviceAddress: null | string

Current connected device address

onconnectionupdates?: ((param) => void)

Type declaration

    • (param): void
    • This is a callback function used when an external device gets connected or disconnected.

      await obniz.ble.initWait();
      obniz.ble.peripheral.onconnectionupdates = function(data){
      console.log("remote device ", data.address, data.status)
      };

      Parameters

      Returns void

Methods

  • This starts a service as peripheral.


    await obniz.ble.initWait();
    // Service without characteristics
    var service1 = new obniz.ble.service({"uuid" : "fff0"});
    obniz.ble.peripheral.addService(service1);

    // Service with characteristics/descriptor
    var service2 = new obniz.ble.service({"uuid" : "fff0"});
    var characteristic = new obniz.ble.characteristic({"uuid" : "FFF1", "text": "Hi"});
    var descriptor = new obniz.ble.descriptor({"uuid" : "2901", "text" : "hello world characteristic"});

    service2.addCharacteristic(characteristic);
    characteristic.addDescriptor(descriptor);

    obniz.ble.peripheral.addService(service2); // call this after all descriptors and characteristics added to service.

    Parameters

    Returns void

Generated using TypeDoc