How to use the buttplug.Endpoints.Rx 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.

github buttplugio / buttplug-js / packages / buttplug-node-bluetoothle-manager / src / ButtplugNodeBluetoothLEDevice.ts View on Github external
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 ||
                   char.properties.indexOf("indicate") !== -1) {
          this._characteristics.set(Endpoints.Rx, char);
        }
      }
    }
    if (this._characteristics.size === 0) {
      const err = `No characteristics found for device ${this.Name}, cannot communicate with device.`;
      throw new ButtplugDeviceException(err);
    }
    this._device.once("disconnect", () => {
      this.emit("deviceremoved");
    });
  }