Skip to content

Commit

Permalink
fix: Correct the protocol used for modern Hismith devices
Browse files Browse the repository at this point in the history
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
  • Loading branch information
blackspherefollower committed Dec 17, 2024
1 parent 343312a commit 0d199e9
Show file tree
Hide file tree
Showing 4 changed files with 103 additions and 25 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -5686,6 +5686,25 @@ protocols:
- 1
messages:
- ScalarCmd
- identifier:
- '1006'
name: Hismith G011
features:
- feature-type: Oscillate
description: Stroker Oscillation Speed
actuator:
step-range:
- 0
- 100
messages:
- ScalarCmd
- feature-type: Vibrate
actuator:
step-range:
- 0
- 1
messages:
- ScalarCmd
- identifier:
- '3001'
name: Wildolo Device
Expand Down Expand Up @@ -5726,7 +5745,20 @@ protocols:
name: Auxfun Sex Machine
- identifier:
- '1005'
- '1102'
name: Hismith Sex Machine
- identifier:
- '1004'
name: Hismith Mini Sex Machine
- identifier:
- '1101'
name: Hismith Servo Sex Machine
- identifier:
- '1402'
name: Hismith Ukulele
- identifier:
- '1501'
name: Hismith PleasureDrive
- identifier:
- '2201'
name: Sinloli Automatic Sex Doll
Expand Down Expand Up @@ -5847,6 +5879,9 @@ protocols:
- 100
messages:
- ScalarCmd
- identifier:
- '2205'
name: Sinloli Aston
communication:
- btle:
names:
Expand All @@ -5855,33 +5890,11 @@ protocols:
- Sinloli-Sherry
- Eropair *
- HISMITH S1
- HISMITH S2 # Servo
- HISMITH S3
- Sinloli Cosima
- Sinloli-Ethel
services:
0000ffe5-0000-1000-8000-00805f9b34fb:
tx: 0000ffe9-0000-1000-8000-00805f9b34fb
0000ff90-0000-1000-8000-00805f9b34fb:
rxblemodel: 0000ff96-0000-1000-8000-00805f9b34fb
hismith-servo:
defaults:
name: Hismith servo device
features:
- feature-type: Position
description: Fucking Machine Position
actuator:
step-range:
- 0
- 100
messages:
- LinearCmd
configurations:
- identifier:
- '1101'
name: Hismith Servo
communication:
- btle:
names:
- HISMITH S2
- Sinloli Aston
services:
0000ffe5-0000-1000-8000-00805f9b34fb:
tx: 0000ffe9-0000-1000-8000-00805f9b34fb
Expand Down
11 changes: 11 additions & 0 deletions buttplug/src/server/device/protocol/hismith.rs
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ use crate::{
};
use async_trait::async_trait;
use std::sync::Arc;
use crate::server::device::protocol::hismith_mini::HismithMiniInitializer;

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

const LEGACY_HISMITHS: [&'static str; 6] = ["1001", "1002", "1003", "3001", "2001", "1006"];

#[async_trait]
impl ProtocolIdentifier for HismithIdentifier {
async fn identify(
Expand All @@ -54,6 +57,14 @@ impl ProtocolIdentifier for HismithIdentifier {
.collect::<String>();
info!("Hismith Device Identifier: {}", identifier);

if !LEGACY_HISMITHS.contains(&identifier.as_str()) {
info!("Not a legacy Hismith, using hismith-mini protocol");
return Ok((
UserDeviceIdentifier::new(hardware.address(), "hismith-mini", &Some(identifier)),
Box::new(HismithMiniInitializer::default()),
));
}

Ok((
UserDeviceIdentifier::new(hardware.address(), "hismith", &Some(identifier)),
Box::new(HismithInitializer::default()),
Expand Down
2 changes: 2 additions & 0 deletions buttplug/tests/test_device_protocols.rs
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ async fn load_test_case(test_file: &str) -> DeviceTestCase {
#[test_case("test_cachito_protocol.yaml" ; "Cachito Protocol")]
#[test_case("test_fredorch_protocol.yaml" ; "Fredorch Protocol")]
#[test_case("test_hismith_auxfun_box.yaml" ; "Hismith Mini Protocol - Auxfun Box")]
#[test_case("test_hismith_v4.yaml" ; "Hismith Mini Protocol - Hismith v4")]
#[test_case("test_hismith_sinloli.yaml" ; "Hismith Mini Protocol - Sinloli")]
#[test_case("test_hismith_thrusting_cup.yaml" ; "Hismith Protocol - Thrusting Cup")]
#[test_case("test_hismith_wildolo.yaml" ; "Hismith Protocol - Wildolo")]
Expand Down Expand Up @@ -129,6 +130,7 @@ async fn test_device_protocols_embedded_v3(test_file: &str) {
#[test_case("test_cachito_protocol.yaml" ; "Cachito Protocol")]
#[test_case("test_fredorch_protocol.yaml" ; "Fredorch Protocol")]
#[test_case("test_hismith_auxfun_box.yaml" ; "Hismith Mini Protocol - Auxfun Box")]
#[test_case("test_hismith_v4.yaml" ; "Hismith Mini Protocol - Hismith v4")]
#[test_case("test_hismith_sinloli.yaml" ; "Hismith Mini Protocol - Sinloli")]
#[test_case("test_hismith_thrusting_cup.yaml" ; "Hismith Protocol - Thrusting Cup")]
#[test_case("test_hismith_wildolo.yaml" ; "Hismith Protocol - Wildolo")]
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
devices:
- identifier:
name: "HISMITH"
expected_name: "Hismith Sex Machine"
device_init:
- !Events
device_index: 0
events:
- !Reads
- endpoint: rxblemodel
data: [0x10, 0x05]
device_commands:
# Commands
- !Messages
device_index: 0
messages:
- !Scalar
- Index: 0
Scalar: 0.5
ActuatorType: Oscillate
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0xCC, 0x03, 0x32, 0x35]
write_with_response: false
- !Messages
device_index: 0
messages:
- !Scalar
- Index: 0
Scalar: 0.1
ActuatorType: Oscillate
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0xCC, 0x03, 0x0a, 0x0d]
write_with_response: false
- !Messages
device_index: 0
messages:
- !Stop
- !Commands
device_index: 0
commands:
- !Write
endpoint: tx
data: [0xCC, 0x03, 0x00, 0x03]
write_with_response: false

0 comments on commit 0d199e9

Please sign in to comment.