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

+9-9
Original file line numberDiff line numberDiff line change
@@ -42,15 +42,15 @@ public void TestStopDeviceCmd()
4242
varexpected=
4343
newList<(byte[],uint)>()
4444
{
45-
(newbyte[]{0x0f,0x03,0x00,0x88,0x00,0x03,0x00,0x00},testUtil.NoCharacteristic),
45+
(newbyte[]{0x0f,0x03,0x00,0x88,0x00,0x03,0x00,0x00},(uint)WeVibeBluetoothInfo.Chrs.Tx),
4646
};
4747

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

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

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

6868
testUtil.TestDeviceMessage(newSingleMotorVibrateCmd(4,0.5),expected,false);
@@ -74,7 +74,7 @@ public void TestVibrateCmd()
7474
varexpected=
7575
newList<(byte[],uint)>()
7676
{
77-
(newbyte[]{0x0f,0x03,0x00,0x88,0x00,0x03,0x00,0x00},testUtil.NoCharacteristic),
77+
(newbyte[]{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
varexpected=
120120
newList<(byte[],uint)>()
121121
{
122-
(newbyte[]{0x0f,0x03,0x00,0x88,0x00,0x03,0x00,0x00},testUtil.NoCharacteristic),
122+
(newbyte[]{0x0f,0x03,0x00,0x88,0x00,0x03,0x00,0x00},(uint)WeVibeBluetoothInfo.Chrs.Tx),
123123
};
124124

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

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

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

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

157-
testUtil.TestDeviceMessage(VibrateCmd.Create(4,1,newdouble[]{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

+4-4
Original file line numberDiff line numberDiff line change
@@ -40,15 +40,15 @@ public void TestStopDeviceCmd()
4040
varexpected=
4141
newList<(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(newSingleMotorVibrateCmd(4,0.5),expected,false);
4747

4848
expected=
4949
newList<(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(newStopDeviceCmd(4),expected,false);
@@ -60,7 +60,7 @@ public void TestSingleMotorVibrateCmd()
6060
varexpected=
6161
newList<(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(newSingleMotorVibrateCmd(4,0.5),expected,false);
@@ -72,7 +72,7 @@ public void TestVibrateCmd()
7272
varexpected=
7373
newList<(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

+16-4
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,13 @@
88
namespaceButtplug.Server.Bluetooth.Devices
99
{
1010
internalclassWeVibeBluetoothInfo:IBluetoothDeviceInfo
11-
{
11+
{
12+
publicenumChrs:uint
13+
{
14+
Tx=0,
15+
Rx,
16+
}
17+
1218
publicGuid[]Services{get;}={newGuid("f000bb03-0451-4000-b000-000000000000")};
1319

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

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

3749
publicIButtplugDeviceCreateDevice(IButtplugLogManageraLogManager,
3850
IBluetoothDeviceInterfaceaInterface)
@@ -146,7 +158,7 @@ private async Task<ButtplugMessage> HandleVibrateCmd(ButtplugDeviceMessage aMsg)
146158
data[5]=0x00;
147159
}
148160

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

Buttplug.Server/Bluetooth/Devices/Youcups.cs

+13-5
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,19 @@
1-
usingSystem;
1+
usingButtplug.Core;
2+
usingButtplug.Core.Messages;
3+
usingSystem;
24
usingSystem.Collections.Generic;
35
usingSystem.Text;
46
usingSystem.Threading.Tasks;
5-
usingButtplug.Core;
6-
usingButtplug.Core.Messages;
77

88
namespaceButtplug.Server.Bluetooth.Devices
99
{
1010
internalclassYoucupsBluetoothInfo:IBluetoothDeviceInfo
1111
{
12+
publicenumChrs:uint
13+
{
14+
Tx=0,
15+
}
16+
1217
publicGuid[]Services{get;}={newGuid("0000fee9-0000-1000-8000-00805f9b34fb")};
1318

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

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

2432
publicIButtplugDeviceCreateDevice(IButtplugLogManageraLogManager,
2533
IBluetoothDeviceInterfaceaInterface)
@@ -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)
close