Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
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 ||
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");
});
}