How to use the buttplug.BluetoothLEProtocolConfiguration 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 / ButtplugNodeBluetoothLEDeviceManager.ts View on Github external
private OpenDevice = async (device: noble.Peripheral): Promise => {
    if (device === undefined) {
      // TODO Throw here?
      return;
    }
    // If the device doesn't even have a name, chances are we aren't interested.
    if (device.advertisement.localName === undefined) {
      return;
    }
    const devConfig = new BluetoothLEProtocolConfiguration([device.advertisement.localName]);
    const foundConfig = DeviceConfigurationManager.Manager.Find(devConfig);
    if (foundConfig === undefined) {
      return;
    }
    this.logger.Debug(`Found configuration for device ${device.advertisement.localName}`);
    const [config, protocolType] = foundConfig;
    const bpDevImpl = new ButtplugNodeBluetoothLEDevice(config as BluetoothLEProtocolConfiguration, device);
    this.logger.Debug(`Connecting to noble device ${device.advertisement.localName}`);
    try {
      await bpDevImpl.Connect();
    } catch (e) {
      let errStr: string;
      switch (e) {
        case ButtplugDeviceException: {
          errStr = e.errorMessage;
          break;