How to use the buttplug.ButtplugDeviceException function in buttplug

To help you get started, we’ve selected a few buttplug examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github buttplugio / buttplug-js / packages / buttplug-node-bluetoothle-manager / src / ButtplugNodeBluetoothLEDevice.ts View on Github external
protected CheckForCharacteristic(aEndpoint: Endpoints) {
    if (this._characteristics.has(aEndpoint)) {
      return;
    }
    const err = `Device ${this._device.advertisement.localName} has no endpoint named ${aEndpoint}`;
    throw new ButtplugDeviceException(err);
  }
github buttplugio / buttplug-js / packages / buttplug-node-bluetoothle-manager / src / ButtplugNodeBluetoothLEDevice.ts View on Github external
public SubscribeToUpdatesInternal = async (aOptions: ButtplugDeviceReadOptions): Promise => {
    this.CheckForCharacteristic(aOptions.Endpoint);
    this._logger.Debug(`Subscripting to updates on noble device ${this._device.advertisement.localName}`);
    const chr = this._characteristics.get(aOptions.Endpoint)!;
    if (chr.properties.find((x) => x === "notify" || x === "indicate") === undefined) {
      const err = `Device ${this._device.advertisement.localName} endpoint ${aOptions.Endpoint}` +
        ` does not have notify or indicate properties.`;
      throw new ButtplugDeviceException(err);
    }
    this._notificationHandlers.set(aOptions.Endpoint, (aData: Buffer, aIsNotification: boolean) => {
      this.CharacteristicValueChanged(aOptions.Endpoint, aData, aIsNotification);
    });
    await util.promisify(chr.subscribe.bind(chr))();
    chr.on("data", this._notificationHandlers.get(aOptions.Endpoint)!);
  }