Skip to content

Commit

Permalink
fix: Fix Lovense motor addressing
Browse files Browse the repository at this point in the history
Vibrate:X drives all motors, VibrateN:X (where 0 <= N < number of
vibrators) drives specific motors.
  • Loading branch information
qdot committed Jun 26, 2018
1 parent cfafc33 commit 86cad2f
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
2 changes: 1 addition & 1 deletion src/server/bluetooth/devices/Lovense.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ export class Lovense extends ButtplugBluetoothDevice {
aMsg.Id);
}
for (const cmd of aMsg.Speeds) {
const index = cmd.Index > 0 ? (cmd.Index + 1).toString(10) : "";
const index = this._specs.VibrateCmd.FeatureCount > 1 ? (cmd.Index + 1).toString(10) : "";
const speed = Math.floor(20 * cmd.Speed);
await this._deviceImpl.WriteString("tx", `Vibrate${index}:${speed};`);
}
Expand Down
6 changes: 3 additions & 3 deletions tests/test-bluetoothdevices.ts
Original file line number Diff line number Diff line change
Expand Up @@ -69,13 +69,13 @@ describe("WebBluetooth library tests", () => {
.rejects
.toHaveProperty("ErrorCode", ErrorClass.ERROR_DEVICE);
await bp.SendDeviceMessage(bp.Devices[0], new VibrateCmd([new SpeedSubcommand(0, 1), new SpeedSubcommand(1, .5)]));
expect(mockBT.txChar.writeValue).toBeCalledWith(Buffer.from("Vibrate:20;"));
expect(mockBT.txChar.writeValue).toBeCalledWith(Buffer.from("Vibrate1:20;"));
expect(mockBT.txChar.writeValue).toBeCalledWith(Buffer.from("Vibrate2:10;"));
await bp.SendDeviceMessage(bp.Devices[0], new SingleMotorVibrateCmd(.5));
expect(mockBT.txChar.writeValue).toBeCalledWith(Buffer.from("Vibrate:10;"));
expect(mockBT.txChar.writeValue).toBeCalledWith(Buffer.from("Vibrate1:10;"));
expect(mockBT.txChar.writeValue).toBeCalledWith(Buffer.from("Vibrate2:10;"));
await bp.StopAllDevices();
expect(mockBT.txChar.writeValue).toBeCalledWith(Buffer.from("Vibrate:0;"));
expect(mockBT.txChar.writeValue).toBeCalledWith(Buffer.from("Vibrate1:0;"));
expect(mockBT.txChar.writeValue).toBeCalledWith(Buffer.from("Vibrate2:0;"));
});

Expand Down

0 comments on commit 86cad2f

Please sign in to comment.