Options
All
  • Public
  • Public/Protected
  • All
Menu

Hierarchy

  • BlePeripheral

Index

Constructors

constructor

  • Parameters

    Returns BlePeripheral

Properties

currentConnectedDeviceAddress

currentConnectedDeviceAddress: BleDeviceAddress | null

Current connected device address

Optional onconnectionupdates

onconnectionupdates: undefined | ((param: BleConnectionUpdateParam) => 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)
};

Methods

addService

  • 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

end

  • end(): void
  • This ends all the peripheral service

    obniz.ble.peripheral.addService(setting);
    obniz.ble.peripheral.end();

    Returns void

getService

  • Get service by UUID

    Parameters

    Returns BleService | null

removeService

  • removeService(uuid: UUID): void
  • Terminate service by UUID

    Parameters

    Returns void

Generated using TypeDoc