Skip to content

Commit c3313f9

Browse files
committed
fix: Revert characteristics on WeVibe and Youcups
Changed WeVibe and Youcups to use characteristic generation. This breaks WeVibe, and I don't have a Youcups to test this on, so it's best to just revert things to how they were. Fixes #423
1 parent 278f51a commit c3313f9

File tree

4 files changed

+42
-22
lines changed

4 files changed

+42
-22
lines changed

Buttplug.Server.Test/Bluetooth/Devices/WeVibeTests.cs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ public void TestStopDeviceCmd()
4242
var expected =
4343
new List<(byte[], uint)>()
4444
{
45-
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, testUtil.NoCharacteristic),
45+
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, (uint)WeVibeBluetoothInfo.Chrs.Tx),
4646
};
4747

4848
testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false);
4949

5050
expected =
5151
new List<(byte[], uint)>()
5252
{
53-
(new byte[] { 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, testUtil.NoCharacteristic),
53+
(new byte[] { 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, (uint)WeVibeBluetoothInfo.Chrs.Tx),
5454
};
5555

5656
testUtil.TestDeviceMessage(new StopDeviceCmd(4), expected, false);
@@ -62,7 +62,7 @@ public void TestSingleMotorVibrateCmd()
6262
var expected =
6363
new List<(byte[], uint)>()
6464
{
65-
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, testUtil.NoCharacteristic),
65+
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, (uint)WeVibeBluetoothInfo.Chrs.Tx),
6666
};
6767

6868
testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false);
@@ -74,7 +74,7 @@ public void TestVibrateCmd()
7474
var expected =
7575
new List<(byte[], uint)>()
7676
{
77-
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, testUtil.NoCharacteristic),
77+
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, (uint)WeVibeBluetoothInfo.Chrs.Tx),
7878
};
7979

8080
testUtil.TestDeviceMessage(VibrateCmd.Create(4, 1, 0.5, 1), expected, false);
@@ -119,15 +119,15 @@ public void TestStopDeviceCmd()
119119
var expected =
120120
new List<(byte[], uint)>()
121121
{
122-
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, testUtil.NoCharacteristic),
122+
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, (uint)WeVibeBluetoothInfo.Chrs.Tx),
123123
};
124124

125125
testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false);
126126

127127
expected =
128128
new List<(byte[], uint)>()
129129
{
130-
(new byte[] { 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, testUtil.NoCharacteristic),
130+
(new byte[] { 0x0f, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00 }, (uint)WeVibeBluetoothInfo.Chrs.Tx),
131131
};
132132

133133
testUtil.TestDeviceMessage(new StopDeviceCmd(4), expected, false);
@@ -139,7 +139,7 @@ public void TestSingleMotorVibrateCmd()
139139
var expected =
140140
new List<(byte[], uint)>()
141141
{
142-
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, testUtil.NoCharacteristic),
142+
(new byte[] { 0x0f, 0x03, 0x00, 0x88, 0x00, 0x03, 0x00, 0x00 }, (uint)WeVibeBluetoothInfo.Chrs.Tx),
143143
};
144144

145145
testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false);
@@ -151,10 +151,10 @@ public void TestVibrateCmd()
151151
var expected =
152152
new List<(byte[], uint)>()
153153
{
154-
(new byte[] { 0x0f, 0x03, 0x00, 0x4B, 0x00, 0x03, 0x00, 0x00 }, testUtil.NoCharacteristic),
154+
(new byte[] { 0x0f, 0x03, 0x00, 0x4B, 0x00, 0x03, 0x00, 0x00 }, (uint)WeVibeBluetoothInfo.Chrs.Tx),
155155
};
156156

157-
testUtil.TestDeviceMessage(VibrateCmd.Create(4, 1, new double[] { 0.25, 0.75 }, 2), expected, false);
157+
testUtil.TestDeviceMessage(VibrateCmd.Create(4, 1, new[] { 0.25, 0.75 }, 2), expected, false);
158158
}
159159

160160
[Test]

Buttplug.Server.Test/Bluetooth/Devices/YoucupsTests.cs

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public void TestStopDeviceCmd()
4040
var expected =
4141
new List<(byte[], uint)>()
4242
{
43-
(Encoding.ASCII.GetBytes("$SYS,4?"), testUtil.NoCharacteristic),
43+
(Encoding.ASCII.GetBytes("$SYS,4?"), (uint)YoucupsBluetoothInfo.Chrs.Tx),
4444
};
4545

4646
testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false);
4747

4848
expected =
4949
new List<(byte[], uint)>()
5050
{
51-
(Encoding.ASCII.GetBytes("$SYS,0?"), testUtil.NoCharacteristic),
51+
(Encoding.ASCII.GetBytes("$SYS,0?"), (uint)YoucupsBluetoothInfo.Chrs.Tx),
5252
};
5353

5454
testUtil.TestDeviceMessage(new StopDeviceCmd(4), expected, false);
@@ -60,7 +60,7 @@ public void TestSingleMotorVibrateCmd()
6060
var expected =
6161
new List<(byte[], uint)>()
6262
{
63-
(Encoding.ASCII.GetBytes("$SYS,4?"), testUtil.NoCharacteristic),
63+
(Encoding.ASCII.GetBytes("$SYS,4?"), (uint)YoucupsBluetoothInfo.Chrs.Tx),
6464
};
6565

6666
testUtil.TestDeviceMessage(new SingleMotorVibrateCmd(4, 0.5), expected, false);
@@ -72,7 +72,7 @@ public void TestVibrateCmd()
7272
var expected =
7373
new List<(byte[], uint)>()
7474
{
75-
(Encoding.ASCII.GetBytes("$SYS,4?"), testUtil.NoCharacteristic),
75+
(Encoding.ASCII.GetBytes("$SYS,4?"), (uint)YoucupsBluetoothInfo.Chrs.Tx),
7676
};
7777

7878
testUtil.TestDeviceMessage(VibrateCmd.Create(4, 1, 0.5, 1), expected, false);

Buttplug.Server/Bluetooth/Devices/WeVibe.cs

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
namespace Buttplug.Server.Bluetooth.Devices
99
{
1010
internal class WeVibeBluetoothInfo : IBluetoothDeviceInfo
11-
{
11+
{
12+
public enum Chrs : uint
13+
{
14+
Tx = 0,
15+
Rx,
16+
}
17+
1218
public Guid[] Services { get; } = { new Guid("f000bb03-0451-4000-b000-000000000000") };
1319

1420
public string[] NamePrefixes { get; } = { };
@@ -32,7 +38,13 @@ internal class WeVibeBluetoothInfo : IBluetoothDeviceInfo
3238
"Wish",
3339
};
3440

35-
public Dictionary<uint, Guid> Characteristics { get; } = new Dictionary<uint, Guid>();
41+
// WeVibe causes the characteristic detector to misidentify characteristics. Do not remove these.
42+
public Dictionary<uint, Guid> Characteristics { get; } = new Dictionary<uint, Guid>()
43+
{
44+
// tx characteristic
45+
{ (uint)Chrs.Tx, new Guid("f000c000-0451-4000-b000-000000000000") },
46+
{ (uint)Chrs.Rx, new Guid("f000b000-0451-4000-b000-000000000000") },
47+
};
3648

3749
public IButtplugDevice CreateDevice(IButtplugLogManager aLogManager,
3850
IBluetoothDeviceInterface aInterface)
@@ -146,7 +158,7 @@ private async Task<ButtplugMessage> HandleVibrateCmd(ButtplugDeviceMessage aMsg)
146158
data[5] = 0x00;
147159
}
148160

149-
return await Interface.WriteValue(aMsg.Id, data);
161+
return await Interface.WriteValue(aMsg.Id, (uint)WeVibeBluetoothInfo.Chrs.Tx, data);
150162
}
151163
}
152-
}
164+
}

Buttplug.Server/Bluetooth/Devices/Youcups.cs

Lines changed: 13 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
using System;
1+
using Buttplug.Core;
2+
using Buttplug.Core.Messages;
3+
using System;
24
using System.Collections.Generic;
35
using System.Text;
46
using System.Threading.Tasks;
5-
using Buttplug.Core;
6-
using Buttplug.Core.Messages;
77

88
namespace Buttplug.Server.Bluetooth.Devices
99
{
1010
internal class YoucupsBluetoothInfo : IBluetoothDeviceInfo
1111
{
12+
public enum Chrs : uint
13+
{
14+
Tx = 0,
15+
}
16+
1217
public Guid[] Services { get; } = { new Guid("0000fee9-0000-1000-8000-00805f9b34fb") };
1318

1419
public string[] NamePrefixes { get; } = { };
@@ -19,7 +24,10 @@ internal class YoucupsBluetoothInfo : IBluetoothDeviceInfo
1924
"Youcups",
2025
};
2126

22-
public Dictionary<uint, Guid> Characteristics { get; } = new Dictionary<uint, Guid>();
27+
public Dictionary<uint, Guid> Characteristics { get; } = new Dictionary<uint, Guid>()
28+
{
29+
{ (uint)Chrs.Tx, new Guid("d44bc439-abfd-45a2-b575-925416129600") },
30+
};
2331

2432
public IButtplugDevice CreateDevice(IButtplugLogManager aLogManager,
2533
IBluetoothDeviceInterface aInterface)
@@ -107,4 +115,4 @@ private async Task<ButtplugMessage> HandleVibrateCmd(ButtplugDeviceMessage aMsg)
107115
Encoding.ASCII.GetBytes($"$SYS,{(int)(_vibratorSpeed * 8), 1}?"));
108116
}
109117
}
110-
}
118+
}

0 commit comments

Comments
 (0)