public void TestRotateCmd() { byte deviceIndex = 1; foreach (var name in _deviceNames) { testUtil = new BluetoothDeviceTestUtils <VorzeSABluetoothInfo>(); testUtil.SetupTest(name); var expected = new byte[] { deviceIndex, 0x1, 50 }; testUtil.TestDeviceMessage( RotateCmd.Create(4, 1, 0.5, false, 1), new List <(byte[], uint)>() { (expected, (uint)VorzeSABluetoothInfo.Chrs.Tx), }, false); expected = new byte[] { deviceIndex, 0x1, 50 + 128 }; testUtil.TestDeviceMessage( RotateCmd.Create(4, 1, 0.5, true, 1), new List <(byte[], uint)>() { (expected, (uint)VorzeSABluetoothInfo.Chrs.Tx), }, false); deviceIndex++; } }
public void TestRotateCmd() { void CheckMsg(RotateCmd aMsg) { aMsg.Id.Should().Be(4); aMsg.DeviceIndex.Should().Be(2); aMsg.Rotations.Count.Should().Be(1); aMsg.Rotations[0].Index.Should().Be(0); aMsg.Rotations[0].Speed.Should().Be(0.5); aMsg.Rotations[0].Clockwise.Should().Be(true); } var msg = new RotateCmd(2, new List <RotateCmd.RotateSubcommand> { new RotateCmd.RotateSubcommand(0, 0.5, true) }, 4); CheckMsg(msg); var newMsg = CheckParsedVersion <RotateCmd>(msg, 1, "[{\"RotateCmd\":{\"Rotations\":[{\"Clockwise\":true,\"Index\":0,\"Speed\":0.5}],\"DeviceIndex\":2,\"Id\":4}}]"); CheckMsg(newMsg); _parser.Invoking(x => x.Serialize(msg, 0)).Should().Throw <ButtplugMessageException>(); }
public void TestRotateCmd() { var msg = new RotateCmd(2, new List <RotateCmd.RotateSubcommand> { new RotateCmd.RotateSubcommand(0, 0.5, true) }, 4); Assert.AreEqual(2, msg.DeviceIndex); Assert.AreEqual(4, msg.Id); Assert.AreEqual(1, msg.Rotations.Count); Assert.AreEqual(0, msg.Rotations[0].Index); Assert.AreEqual(0.5, msg.Rotations[0].Speed); Assert.True(msg.Rotations[0].Clockwise); var str1 = _parser.Serialize(msg, 1); Assert.AreEqual( "[{\"RotateCmd\":{\"Rotations\":[{\"Index\":0,\"Clockwise\":true,\"Speed\":0.5}],\"DeviceIndex\":2,\"Id\":4}}]", str1); var msgs = _parser.Deserialize(str1); Assert.AreEqual(1, msgs.Length); Assert.True(msgs[0] is RotateCmd); msg = (RotateCmd)msgs[0]; Assert.AreEqual(2, msg.DeviceIndex); Assert.AreEqual(4, msg.Id); Assert.AreEqual(1, msg.Rotations.Count); Assert.AreEqual(0, msg.Rotations[0].Index); Assert.AreEqual(0.5, msg.Rotations[0].Speed); Assert.True(msg.Rotations[0].Clockwise); var str0 = _parser.Serialize(msg, 0); Assert.AreEqual("[{\"Error\":{\"ErrorCode\":3,\"ErrorMessage\":\"No backwards compatible version for message #RotateCmd!\",\"Id\":4}}]", str0); }
private async Task <ButtplugMessage> HandleStopDeviceCmd(ButtplugDeviceMessage aMsg, CancellationToken aToken) { BpLogger.Debug("Stopping Device " + Name); await HandleSingleMotorVibrateCmd(new SingleMotorVibrateCmd(aMsg.DeviceIndex, 0, aMsg.Id), aToken).ConfigureAwait(false); await HandleRotateCmd(RotateCmd.Create(0, false, 1), aToken); return(new Ok(aMsg.Id)); }
public void TestInvalidVibrateCmd() { testUtil.TestInvalidDeviceMessage(RotateCmd.Create(4, 1, 0.5, true, 0)); testUtil.TestInvalidDeviceMessage(RotateCmd.Create(4, 1, 0.5, true, 2)); testUtil.TestInvalidDeviceMessage( new VibrateCmd(4, new List <VibrateCmd.VibrateSubcommand>() { new VibrateCmd.VibrateSubcommand(0xffffffff, 0.5), })); }
public async Task TestRotateCmd() { var expected = new List <(byte[], string)>() { (new byte[] { 0xaf, 0x2a, 0x7f, 0x2a, 0x7f, 0x2a, 0x7f, 0x2a, 0x7f, 0x2a, 0x7f, 0x2a, 0x7f, 0x2a, 0x7f, 0x9F, 0xec }, Endpoints.Tx), }; await testUtil.TestDeviceMessage(RotateCmd.Create(4, 1, 0.5, true, 1), expected, false); }
private async Task <ButtplugMessage> HandleStopDeviceCmd(ButtplugDeviceMessage aMsg) { BpLogger.Debug("Stopping Device " + Name); if (_deviceType == LovenseDeviceType.Nora) { await HandleRotateCmd(RotateCmd.Create(aMsg.DeviceIndex, aMsg.Id, 0, _clockwise, 1)); } return(await HandleSingleMotorVibrateCmd(new SingleMotorVibrateCmd(aMsg.DeviceIndex, 0, aMsg.Id))); }
private async Task <ButtplugMessage> HandleStopDeviceCmd(ButtplugDeviceMessage aMsg, CancellationToken aToken) { BpLogger.Debug("Stopping Device " + Name); if (_deviceType == LovenseDeviceType.Nora) { await HandleRotateCmd(RotateCmd.Create(aMsg.DeviceIndex, aMsg.Id, 0, _clockwise, 1), aToken).ConfigureAwait(false); } return(await HandleSingleMotorVibrateCmd(new SingleMotorVibrateCmd(aMsg.DeviceIndex, 0, aMsg.Id), aToken).ConfigureAwait(false)); }
public async Task TestRotateCmd(string aDeviceName, byte aPrefix) { testUtil = new BluetoothDeviceTestUtils <VorzeSABluetoothInfo>(); await testUtil.SetupTest(aDeviceName); var expected = new byte[] { aPrefix, 0x1, 50 }; await testUtil.TestDeviceMessage( RotateCmd.Create(4, 1, 0.5, false, 1), new List <(byte[], uint)> { (expected, (uint)VorzeSABluetoothInfo.Chrs.Tx), }, false);
public async Task TestRotateCmd(string aDeviceName, byte aPrefix) { testUtil = new ProtocolTestUtils(); await testUtil.SetupTest <VorzeSAProtocol>(aDeviceName); var expected = new byte[] { aPrefix, 0x1, 50 }; await testUtil.TestDeviceMessage( RotateCmd.Create(4, 1, 0.5, false, 1), new List <(byte[], string)> { (expected, Endpoints.Tx), }, false);
public void TestInvalidVibrateCmd() { foreach (var name in _deviceNames) { testUtil = new BluetoothDeviceTestUtils <VorzeSABluetoothInfo>(); testUtil.SetupTest(name); testUtil.TestInvalidDeviceMessage(RotateCmd.Create(4, 1, 0.5, false, 0)); testUtil.TestInvalidDeviceMessage(RotateCmd.Create(4, 1, 0.5, false, 2)); testUtil.TestInvalidDeviceMessage( new RotateCmd(4, new List <RotateCmd.RotateSubcommand>() { new RotateCmd.RotateSubcommand(0xffffffff, 0.5, true), })); } }
public void TestRotateCmd() { var expected = new List <(byte[], uint)>() { (Encoding.ASCII.GetBytes("Rotate:10;"), testUtil.NoCharacteristic), }; testUtil.TestDeviceMessage(RotateCmd.Create(4, 1, 0.5, true, 1), expected, false); expected = new List <(byte[], uint)>() { (Encoding.ASCII.GetBytes("RotateChange;"), testUtil.NoCharacteristic), }; testUtil.TestDeviceMessage(RotateCmd.Create(4, 1, 0.5, false, 1), expected, false); }
public async Task TestRotateCmd() { var expected = new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("Rotate:10;"), Endpoints.Tx), }; await testUtil.TestDeviceMessage(RotateCmd.Create(4, 1, 0.5, true, 1), expected, false); expected = new List <(byte[], string)>() { (Encoding.ASCII.GetBytes("RotateChange;"), Endpoints.Tx), }; await testUtil.TestDeviceMessage(RotateCmd.Create(4, 1, 0.5, false, 1), expected, false); }
public async Task TestStopDeviceCmd() { var expected = new List <(byte[], uint)>() { (Encoding.ASCII.GetBytes("Rotate:10;"), testUtil.NoCharacteristic), }; await testUtil.TestDeviceMessage(RotateCmd.Create(4, 1, 0.5, true, 1), expected, false); expected = new List <(byte[], uint)>() { (Encoding.ASCII.GetBytes("Rotate:0;"), testUtil.NoCharacteristic), }; await testUtil.TestDeviceMessage(new StopDeviceCmd(4), expected, false); }
public async Task SendRotateCmd(double aSpeed, bool aClockwise) { CheckAllowedMessageType <RotateCmd>(); await SendMessageAsync(RotateCmd.Create(aSpeed, aClockwise, GetMessageAttributes <RotateCmd>().FeatureCount.Value)).ConfigureAwait(false); }