Skip to content

Commit 71b2dda

Browse files
blackspherefollowerqdot
authored andcommitted
fix: Correct the protocol used for modern Hismith devices
This change is a bit of a cheat: legacy Hismith devices are hardcoded in the protocol and if the identifier doesn't match, the hismith-mini protocol is invoked instead. Fixes #682
1 parent 77da427 commit 71b2dda

File tree

5 files changed

+172
-72
lines changed

5 files changed

+172
-72
lines changed

buttplug/buttplug-device-config/build-config/buttplug-device-config-v3.json

Lines changed: 69 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -9983,6 +9983,39 @@
99839983
}
99849984
]
99859985
},
9986+
{
9987+
"identifier": [
9988+
"1006"
9989+
],
9990+
"name": "Hismith G011",
9991+
"features": [
9992+
{
9993+
"feature-type": "Oscillate",
9994+
"description": "Stroker Oscillation Speed",
9995+
"actuator": {
9996+
"step-range": [
9997+
0,
9998+
100
9999+
],
10000+
"messages": [
10001+
"ScalarCmd"
10002+
]
10003+
}
10004+
},
10005+
{
10006+
"feature-type": "Vibrate",
10007+
"actuator": {
10008+
"step-range": [
10009+
0,
10010+
1
10011+
],
10012+
"messages": [
10013+
"ScalarCmd"
10014+
]
10015+
}
10016+
}
10017+
]
10018+
},
998610019
{
998710020
"identifier": [
998810021
"3001"
@@ -10052,10 +10085,35 @@
1005210085
},
1005310086
{
1005410087
"identifier": [
10055-
"1005"
10088+
"1005",
10089+
"1102"
1005610090
],
1005710091
"name": "Hismith Sex Machine"
1005810092
},
10093+
{
10094+
"identifier": [
10095+
"1004"
10096+
],
10097+
"name": "Hismith Mini Sex Machine"
10098+
},
10099+
{
10100+
"identifier": [
10101+
"1101"
10102+
],
10103+
"name": "Hismith Servo Sex Machine"
10104+
},
10105+
{
10106+
"identifier": [
10107+
"1402"
10108+
],
10109+
"name": "Hismith Ukulele"
10110+
},
10111+
{
10112+
"identifier": [
10113+
"1501"
10114+
],
10115+
"name": "Hismith PleasureDrive"
10116+
},
1005910117
{
1006010118
"identifier": [
1006110119
"2201"
@@ -10259,6 +10317,12 @@
1025910317
}
1026010318
}
1026110319
]
10320+
},
10321+
{
10322+
"identifier": [
10323+
"2205"
10324+
],
10325+
"name": "Sinloli Aston"
1026210326
}
1026310327
],
1026410328
"communication": [
@@ -10270,53 +10334,11 @@
1027010334
"Sinloli-Sherry",
1027110335
"Eropair *",
1027210336
"HISMITH S1",
10337+
"HISMITH S2",
10338+
"HISMITH S3",
1027310339
"Sinloli Cosima",
10274-
"Sinloli-Ethel"
10275-
],
10276-
"services": {
10277-
"0000ffe5-0000-1000-8000-00805f9b34fb": {
10278-
"tx": "0000ffe9-0000-1000-8000-00805f9b34fb"
10279-
},
10280-
"0000ff90-0000-1000-8000-00805f9b34fb": {
10281-
"rxblemodel": "0000ff96-0000-1000-8000-00805f9b34fb"
10282-
}
10283-
}
10284-
}
10285-
}
10286-
]
10287-
},
10288-
"hismith-servo": {
10289-
"defaults": {
10290-
"name": "Hismith servo device",
10291-
"features": [
10292-
{
10293-
"feature-type": "Position",
10294-
"description": "Fucking Machine Position",
10295-
"actuator": {
10296-
"step-range": [
10297-
0,
10298-
100
10299-
],
10300-
"messages": [
10301-
"LinearCmd"
10302-
]
10303-
}
10304-
}
10305-
]
10306-
},
10307-
"configurations": [
10308-
{
10309-
"identifier": [
10310-
"1101"
10311-
],
10312-
"name": "Hismith Servo"
10313-
}
10314-
],
10315-
"communication": [
10316-
{
10317-
"btle": {
10318-
"names": [
10319-
"HISMITH S2"
10340+
"Sinloli-Ethel",
10341+
"Sinloli Aston"
1032010342
],
1032110343
"services": {
1032210344
"0000ffe5-0000-1000-8000-00805f9b34fb": {

buttplug/buttplug-device-config/device-config-v3/buttplug-device-config-v3.yml

Lines changed: 38 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -5686,6 +5686,25 @@ protocols:
56865686
- 1
56875687
messages:
56885688
- ScalarCmd
5689+
- identifier:
5690+
- '1006'
5691+
name: Hismith G011
5692+
features:
5693+
- feature-type: Oscillate
5694+
description: Stroker Oscillation Speed
5695+
actuator:
5696+
step-range:
5697+
- 0
5698+
- 100
5699+
messages:
5700+
- ScalarCmd
5701+
- feature-type: Vibrate
5702+
actuator:
5703+
step-range:
5704+
- 0
5705+
- 1
5706+
messages:
5707+
- ScalarCmd
56895708
- identifier:
56905709
- '3001'
56915710
name: Wildolo Device
@@ -5726,7 +5745,20 @@ protocols:
57265745
name: Auxfun Sex Machine
57275746
- identifier:
57285747
- '1005'
5748+
- '1102'
57295749
name: Hismith Sex Machine
5750+
- identifier:
5751+
- '1004'
5752+
name: Hismith Mini Sex Machine
5753+
- identifier:
5754+
- '1101'
5755+
name: Hismith Servo Sex Machine
5756+
- identifier:
5757+
- '1402'
5758+
name: Hismith Ukulele
5759+
- identifier:
5760+
- '1501'
5761+
name: Hismith PleasureDrive
57305762
- identifier:
57315763
- '2201'
57325764
name: Sinloli Automatic Sex Doll
@@ -5847,6 +5879,9 @@ protocols:
58475879
- 100
58485880
messages:
58495881
- ScalarCmd
5882+
- identifier:
5883+
- '2205'
5884+
name: Sinloli Aston
58505885
communication:
58515886
- btle:
58525887
names:
@@ -5855,33 +5890,11 @@ protocols:
58555890
- Sinloli-Sherry
58565891
- Eropair *
58575892
- HISMITH S1
5893+
- HISMITH S2 # Servo
5894+
- HISMITH S3
58585895
- Sinloli Cosima
58595896
- Sinloli-Ethel
5860-
services:
5861-
0000ffe5-0000-1000-8000-00805f9b34fb:
5862-
tx: 0000ffe9-0000-1000-8000-00805f9b34fb
5863-
0000ff90-0000-1000-8000-00805f9b34fb:
5864-
rxblemodel: 0000ff96-0000-1000-8000-00805f9b34fb
5865-
hismith-servo:
5866-
defaults:
5867-
name: Hismith servo device
5868-
features:
5869-
- feature-type: Position
5870-
description: Fucking Machine Position
5871-
actuator:
5872-
step-range:
5873-
- 0
5874-
- 100
5875-
messages:
5876-
- LinearCmd
5877-
configurations:
5878-
- identifier:
5879-
- '1101'
5880-
name: Hismith Servo
5881-
communication:
5882-
- btle:
5883-
names:
5884-
- HISMITH S2
5897+
- Sinloli Aston
58855898
services:
58865899
0000ffe5-0000-1000-8000-00805f9b34fb:
58875900
tx: 0000ffe9-0000-1000-8000-00805f9b34fb

buttplug/src/server/device/protocol/hismith.rs

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ use crate::{
1616
};
1717
use async_trait::async_trait;
1818
use std::sync::Arc;
19+
use crate::server::device::protocol::hismith_mini::HismithMiniInitializer;
1920

2021
pub mod setup {
2122
use crate::server::device::protocol::{ProtocolIdentifier, ProtocolIdentifierFactory};
@@ -36,6 +37,8 @@ pub mod setup {
3637
#[derive(Default)]
3738
pub struct HismithIdentifier {}
3839

40+
const LEGACY_HISMITHS: [&'static str; 6] = ["1001", "1002", "1003", "3001", "2001", "1006"];
41+
3942
#[async_trait]
4043
impl ProtocolIdentifier for HismithIdentifier {
4144
async fn identify(
@@ -54,6 +57,14 @@ impl ProtocolIdentifier for HismithIdentifier {
5457
.collect::<String>();
5558
info!("Hismith Device Identifier: {}", identifier);
5659

60+
if !LEGACY_HISMITHS.contains(&identifier.as_str()) {
61+
info!("Not a legacy Hismith, using hismith-mini protocol");
62+
return Ok((
63+
UserDeviceIdentifier::new(hardware.address(), "hismith-mini", &Some(identifier)),
64+
Box::new(HismithMiniInitializer::default()),
65+
));
66+
}
67+
5768
Ok((
5869
UserDeviceIdentifier::new(hardware.address(), "hismith", &Some(identifier)),
5970
Box::new(HismithInitializer::default()),

buttplug/tests/test_device_protocols.rs

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ async fn load_test_case(test_file: &str) -> DeviceTestCase {
2424
#[test_case("test_cachito_protocol.yaml" ; "Cachito Protocol")]
2525
#[test_case("test_fredorch_protocol.yaml" ; "Fredorch Protocol")]
2626
#[test_case("test_hismith_auxfun_box.yaml" ; "Hismith Mini Protocol - Auxfun Box")]
27+
#[test_case("test_hismith_v4.yaml" ; "Hismith Mini Protocol - Hismith v4")]
2728
#[test_case("test_hismith_sinloli.yaml" ; "Hismith Mini Protocol - Sinloli")]
2829
#[test_case("test_hismith_thrusting_cup.yaml" ; "Hismith Protocol - Thrusting Cup")]
2930
#[test_case("test_hismith_wildolo.yaml" ; "Hismith Protocol - Wildolo")]
@@ -129,6 +130,7 @@ async fn test_device_protocols_embedded_v3(test_file: &str) {
129130
#[test_case("test_cachito_protocol.yaml" ; "Cachito Protocol")]
130131
#[test_case("test_fredorch_protocol.yaml" ; "Fredorch Protocol")]
131132
#[test_case("test_hismith_auxfun_box.yaml" ; "Hismith Mini Protocol - Auxfun Box")]
133+
#[test_case("test_hismith_v4.yaml" ; "Hismith Mini Protocol - Hismith v4")]
132134
#[test_case("test_hismith_sinloli.yaml" ; "Hismith Mini Protocol - Sinloli")]
133135
#[test_case("test_hismith_thrusting_cup.yaml" ; "Hismith Protocol - Thrusting Cup")]
134136
#[test_case("test_hismith_wildolo.yaml" ; "Hismith Protocol - Wildolo")]
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
1+
devices:
2+
- identifier:
3+
name: "HISMITH"
4+
expected_name: "Hismith Sex Machine"
5+
device_init:
6+
- !Events
7+
device_index: 0
8+
events:
9+
- !Reads
10+
- endpoint: rxblemodel
11+
data: [0x10, 0x05]
12+
device_commands:
13+
# Commands
14+
- !Messages
15+
device_index: 0
16+
messages:
17+
- !Scalar
18+
- Index: 0
19+
Scalar: 0.5
20+
ActuatorType: Oscillate
21+
- !Commands
22+
device_index: 0
23+
commands:
24+
- !Write
25+
endpoint: tx
26+
data: [0xCC, 0x03, 0x32, 0x35]
27+
write_with_response: false
28+
- !Messages
29+
device_index: 0
30+
messages:
31+
- !Scalar
32+
- Index: 0
33+
Scalar: 0.1
34+
ActuatorType: Oscillate
35+
- !Commands
36+
device_index: 0
37+
commands:
38+
- !Write
39+
endpoint: tx
40+
data: [0xCC, 0x03, 0x0a, 0x0d]
41+
write_with_response: false
42+
- !Messages
43+
device_index: 0
44+
messages:
45+
- !Stop
46+
- !Commands
47+
device_index: 0
48+
commands:
49+
- !Write
50+
endpoint: tx
51+
data: [0xCC, 0x03, 0x00, 0x03]
52+
write_with_response: false

0 commit comments

Comments
 (0)