Ejemplo n.º 1
0
        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++;
            }
        }
Ejemplo n.º 2
0
        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));
        }
Ejemplo n.º 3
0
 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),
     }));
 }
Ejemplo n.º 4
0
        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);
        }
Ejemplo n.º 5
0
        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)));
        }
Ejemplo n.º 6
0
        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));
        }
Ejemplo n.º 7
0
        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);
Ejemplo n.º 8
0
        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);
Ejemplo n.º 9
0
 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),
         }));
     }
 }
Ejemplo n.º 10
0
        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);
        }
Ejemplo n.º 11
0
        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);
        }
Ejemplo n.º 12
0
        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);
        }
Ejemplo n.º 13
0
 public async Task SendRotateCmd(double aSpeed, bool aClockwise)
 {
     CheckAllowedMessageType <RotateCmd>();
     await SendMessageAsync(RotateCmd.Create(aSpeed, aClockwise, GetMessageAttributes <RotateCmd>().FeatureCount.Value)).ConfigureAwait(false);
 }