How to use the buttplug.GetEndpoint 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
if (services.length === 0) {
      const err = `Cannot find any valid services on device ${this._device.advertisement.localName}`;
      throw new ButtplugDeviceException(err);
    }

    for (const service of services) {
      this._logger.Debug(`Found service ${service.uuid} for device ${this._device.advertisement.localName}`);
      const discoverCharsAsync: (x: string[]) => noble.Characteristic[] =
        util.promisify(service.discoverCharacteristics.bind(service));
      const serviceUuid = this.NobleToRegularUuid(service.uuid);
      const chrs = this._deviceInfo.Services.get(serviceUuid)!;
      if (chrs.size !== 0) {
        for (const [name, uuid] of chrs.entries()) {
          const nobleChr = this.RegularToNobleUuid(uuid);
          this._logger.Debug(`Setting up endpoint ${name} ${uuid} for device ${this.Name}`);
          this._characteristics.set(GetEndpoint(name)!,
                                    (await discoverCharsAsync([nobleChr]))[0]);
        }
        continue;
      }
      // If no characteristics are present in the DeviceInfo block, we assume that
      // we're connecting to a simple rx/tx service, and can query to figure out
      // characteristics. Assume that the characteristics have tx/rx references.
      const characteristics = await discoverCharsAsync([]);
      for (const char of characteristics) {
        if (char.properties.indexOf("write") !== -1 ||
            char.properties.indexOf("writeWithoutResponse") !== -1 ||
            char.properties.indexOf("reliableWrite") !== -1) {
          this._characteristics.set(Endpoints.Tx, char);
        } else if (char.properties.indexOf("read") !== -1 ||
                   char.properties.indexOf("broadcast") !== -1 ||
                   char.properties.indexOf("notify") !== -1 ||