From 275d8d6f825d630ebf50a9e070eef013f768dfe1 Mon Sep 17 00:00:00 2001 From: blackspherefollower Date: Fri, 24 May 2024 19:23:10 +0100 Subject: [PATCH] fix: Correct identification of early Satisfyer devices This change passes the ProtocolCommunicationSpecifier down into ProtocolIdentifier::identify(), which affects all protocols, but means that the identify() method can access the same data that was used to decide that this was a suitable protocol implementation in the first place. Fixes #547 --- buttplug/src/server/device/protocol/ankni.rs | 1 + buttplug/src/server/device/protocol/foreo.rs | 1 + .../src/server/device/protocol/fredorch.rs | 1 + .../server/device/protocol/fredorch_rotary.rs | 1 + buttplug/src/server/device/protocol/hgod.rs | 1 + .../src/server/device/protocol/hismith.rs | 2 ++ .../server/device/protocol/hismith_mini.rs | 2 ++ buttplug/src/server/device/protocol/joyhub.rs | 1 + .../src/server/device/protocol/joyhub_v2.rs | 1 + .../src/server/device/protocol/kiiroo_v2.rs | 5 +++- .../device/protocol/kiiroo_v21_initialized.rs | 5 +++- .../server/device/protocol/lelo_harmony.rs | 5 +++- .../src/server/device/protocol/lelof1s.rs | 5 +++- .../src/server/device/protocol/lelof1sv2.rs | 5 +++- buttplug/src/server/device/protocol/leten.rs | 1 + .../src/server/device/protocol/lioness.rs | 1 + .../server/device/protocol/longlosttouch.rs | 5 +++- .../server/device/protocol/lovedistance.rs | 5 +++- .../src/server/device/protocol/lovense.rs | 6 +++- .../protocol/lovense_connect_service.rs | 5 +++- .../device/protocol/metaxsire_repeat.rs | 1 + .../server/device/protocol/metaxsire_v2.rs | 5 +++- .../server/device/protocol/metaxsire_v3.rs | 1 + .../src/server/device/protocol/mizzzee_v3.rs | 5 +++- buttplug/src/server/device/protocol/mod.rs | 3 ++ .../src/server/device/protocol/monsterpub.rs | 2 ++ .../src/server/device/protocol/mysteryvibe.rs | 5 +++- .../server/device/protocol/mysteryvibe_v2.rs | 5 +++- .../server/device/protocol/nintendo_joycon.rs | 1 + buttplug/src/server/device/protocol/nobra.rs | 5 +++- buttplug/src/server/device/protocol/patoo.rs | 6 +++- .../src/server/device/protocol/prettylove.rs | 6 +++- .../src/server/device/protocol/satisfyer.rs | 28 +++++++++++++++++-- .../server/device/protocol/svakom_avaneo.rs | 5 +++- .../server/device/protocol/svakom_dt250a.rs | 5 +++- .../src/server/device/protocol/svakom_iker.rs | 5 +++- .../src/server/device/protocol/svakom_sam.rs | 1 + .../server/device/protocol/svakom_suitcase.rs | 5 +++- .../server/device/protocol/svakom_tarax.rs | 1 + .../src/server/device/protocol/svakom_v5.rs | 5 +++- .../server/device/protocol/thehandy/mod.rs | 5 +++- .../src/server/device/protocol/vibcrafter.rs | 1 + .../server/device/protocol/vibratissimo.rs | 2 ++ .../src/server/device/protocol/vorze_sa.rs | 1 + buttplug/src/server/device/protocol/wetoy.rs | 1 + buttplug/src/server/device/protocol/wevibe.rs | 1 + buttplug/src/server/device/protocol/youou.rs | 2 ++ buttplug/src/server/device/server_device.rs | 5 ++-- 48 files changed, 151 insertions(+), 26 deletions(-) diff --git a/buttplug/src/server/device/protocol/ankni.rs b/buttplug/src/server/device/protocol/ankni.rs index c9863699..181f2666 100644 --- a/buttplug/src/server/device/protocol/ankni.rs +++ b/buttplug/src/server/device/protocol/ankni.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/foreo.rs b/buttplug/src/server/device/protocol/foreo.rs index ad736e38..669d3a2f 100644 --- a/buttplug/src/server/device/protocol/foreo.rs +++ b/buttplug/src/server/device/protocol/foreo.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/fredorch.rs b/buttplug/src/server/device/protocol/fredorch.rs index eec669e9..e8e62585 100644 --- a/buttplug/src/server/device/protocol/fredorch.rs +++ b/buttplug/src/server/device/protocol/fredorch.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/fredorch_rotary.rs b/buttplug/src/server/device/protocol/fredorch_rotary.rs index fc680536..ba87ba5c 100644 --- a/buttplug/src/server/device/protocol/fredorch_rotary.rs +++ b/buttplug/src/server/device/protocol/fredorch_rotary.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/hgod.rs b/buttplug/src/server/device/protocol/hgod.rs index 6de697bb..e75614b4 100644 --- a/buttplug/src/server/device/protocol/hgod.rs +++ b/buttplug/src/server/device/protocol/hgod.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/hismith.rs b/buttplug/src/server/device/protocol/hismith.rs index 7bc0fa7a..ab565f0f 100644 --- a/buttplug/src/server/device/protocol/hismith.rs +++ b/buttplug/src/server/device/protocol/hismith.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ @@ -40,6 +41,7 @@ impl ProtocolIdentifier for HismithIdentifier { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { let result = hardware .read_value(&HardwareReadCmd::new(Endpoint::RxBLEModel, 128, 500)) diff --git a/buttplug/src/server/device/protocol/hismith_mini.rs b/buttplug/src/server/device/protocol/hismith_mini.rs index 824f4c20..cec5530c 100644 --- a/buttplug/src/server/device/protocol/hismith_mini.rs +++ b/buttplug/src/server/device/protocol/hismith_mini.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, @@ -43,6 +44,7 @@ impl ProtocolIdentifier for HismithMiniIdentifier { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { let result = hardware .read_value(&HardwareReadCmd::new(Endpoint::RxBLEModel, 128, 500)) diff --git a/buttplug/src/server/device/protocol/joyhub.rs b/buttplug/src/server/device/protocol/joyhub.rs index add5efd9..33b98c83 100644 --- a/buttplug/src/server/device/protocol/joyhub.rs +++ b/buttplug/src/server/device/protocol/joyhub.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/joyhub_v2.rs b/buttplug/src/server/device/protocol/joyhub_v2.rs index e9975b8d..6fbf3790 100644 --- a/buttplug/src/server/device/protocol/joyhub_v2.rs +++ b/buttplug/src/server/device/protocol/joyhub_v2.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/kiiroo_v2.rs b/buttplug/src/server/device/protocol/kiiroo_v2.rs index c80cf6ae..07935c8d 100644 --- a/buttplug/src/server/device/protocol/kiiroo_v2.rs +++ b/buttplug/src/server/device/protocol/kiiroo_v2.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/kiiroo_v21_initialized.rs b/buttplug/src/server/device/protocol/kiiroo_v21_initialized.rs index 18d98794..50933c24 100644 --- a/buttplug/src/server/device/protocol/kiiroo_v21_initialized.rs +++ b/buttplug/src/server/device/protocol/kiiroo_v21_initialized.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/lelo_harmony.rs b/buttplug/src/server/device/protocol/lelo_harmony.rs index 295d49aa..20ca294b 100644 --- a/buttplug/src/server/device/protocol/lelo_harmony.rs +++ b/buttplug/src/server/device/protocol/lelo_harmony.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/lelof1s.rs b/buttplug/src/server/device/protocol/lelof1s.rs index 789a62e9..3f36f7b6 100644 --- a/buttplug/src/server/device/protocol/lelof1s.rs +++ b/buttplug/src/server/device/protocol/lelof1s.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/lelof1sv2.rs b/buttplug/src/server/device/protocol/lelof1sv2.rs index d6a468d6..82e63914 100644 --- a/buttplug/src/server/device/protocol/lelof1sv2.rs +++ b/buttplug/src/server/device/protocol/lelof1sv2.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/leten.rs b/buttplug/src/server/device/protocol/leten.rs index c86f2f0a..c5b257f9 100644 --- a/buttplug/src/server/device/protocol/leten.rs +++ b/buttplug/src/server/device/protocol/leten.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/lioness.rs b/buttplug/src/server/device/protocol/lioness.rs index 7bb12340..47489f4c 100644 --- a/buttplug/src/server/device/protocol/lioness.rs +++ b/buttplug/src/server/device/protocol/lioness.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/longlosttouch.rs b/buttplug/src/server/device/protocol/longlosttouch.rs index 829cf6fd..9d3edb2f 100644 --- a/buttplug/src/server/device/protocol/longlosttouch.rs +++ b/buttplug/src/server/device/protocol/longlosttouch.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::util::async_manager; use crate::{ core::{errors::ButtplugDeviceError, message, message::Endpoint}, diff --git a/buttplug/src/server/device/protocol/lovedistance.rs b/buttplug/src/server/device/protocol/lovedistance.rs index 530b4787..908038e9 100644 --- a/buttplug/src/server/device/protocol/lovedistance.rs +++ b/buttplug/src/server/device/protocol/lovedistance.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/lovense.rs b/buttplug/src/server/device/protocol/lovense.rs index 88d1b7f5..b743e1bd 100644 --- a/buttplug/src/server/device/protocol/lovense.rs +++ b/buttplug/src/server/device/protocol/lovense.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, @@ -84,6 +87,7 @@ impl ProtocolIdentifier for LovenseIdentifier { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { let mut event_receiver = hardware.event_stream(); let mut count = 0; diff --git a/buttplug/src/server/device/protocol/lovense_connect_service.rs b/buttplug/src/server/device/protocol/lovense_connect_service.rs index 3826aa32..f3417d47 100644 --- a/buttplug/src/server/device/protocol/lovense_connect_service.rs +++ b/buttplug/src/server/device/protocol/lovense_connect_service.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/metaxsire_repeat.rs b/buttplug/src/server/device/protocol/metaxsire_repeat.rs index 19fd7a50..9e2857af 100644 --- a/buttplug/src/server/device/protocol/metaxsire_repeat.rs +++ b/buttplug/src/server/device/protocol/metaxsire_repeat.rs @@ -7,6 +7,7 @@ use crate::core::message::ActuatorType; use crate::core::message::ActuatorType::{Constrict, Rotate, Vibrate}; +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/metaxsire_v2.rs b/buttplug/src/server/device/protocol/metaxsire_v2.rs index 3867f692..2eea74c0 100644 --- a/buttplug/src/server/device/protocol/metaxsire_v2.rs +++ b/buttplug/src/server/device/protocol/metaxsire_v2.rs @@ -6,7 +6,10 @@ // for full license information. use crate::core::message::ActuatorType; -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::server::device::hardware::Hardware; use crate::server::device::protocol::ProtocolInitializer; use crate::{ diff --git a/buttplug/src/server/device/protocol/metaxsire_v3.rs b/buttplug/src/server/device/protocol/metaxsire_v3.rs index 5656befc..1363c8b1 100644 --- a/buttplug/src/server/device/protocol/metaxsire_v3.rs +++ b/buttplug/src/server/device/protocol/metaxsire_v3.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/mizzzee_v3.rs b/buttplug/src/server/device/protocol/mizzzee_v3.rs index c0e7fe0f..f261afd9 100644 --- a/buttplug/src/server/device/protocol/mizzzee_v3.rs +++ b/buttplug/src/server/device/protocol/mizzzee_v3.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/mod.rs b/buttplug/src/server/device/protocol/mod.rs index f8f8de86..733a5b82 100644 --- a/buttplug/src/server/device/protocol/mod.rs +++ b/buttplug/src/server/device/protocol/mod.rs @@ -580,6 +580,7 @@ pub trait ProtocolIdentifier: Sync + Send { async fn identify( &mut self, hardware: Arc, + specifier: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError>; } @@ -611,6 +612,7 @@ impl ProtocolIdentifier for GenericProtocolIdentifier { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { let device_identifier = UserDeviceIdentifier::new( hardware.address(), @@ -935,6 +937,7 @@ macro_rules! generic_protocol_initializer_setup { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { Ok((UserDeviceIdentifier::new(hardware.address(), $protocol_identifier, &Some(hardware.name().to_owned())), Box::new([< $protocol_name Initializer >]::default()))) } diff --git a/buttplug/src/server/device/protocol/monsterpub.rs b/buttplug/src/server/device/protocol/monsterpub.rs index b0e5efdb..808be46f 100644 --- a/buttplug/src/server/device/protocol/monsterpub.rs +++ b/buttplug/src/server/device/protocol/monsterpub.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, @@ -44,6 +45,7 @@ impl ProtocolIdentifier for MonsterPubIdentifier { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { let read_resp = hardware .read_value(&HardwareReadCmd::new(Endpoint::RxBLEModel, 32, 500)) diff --git a/buttplug/src/server/device/protocol/mysteryvibe.rs b/buttplug/src/server/device/protocol/mysteryvibe.rs index f8e1ddba..ff49d177 100644 --- a/buttplug/src/server/device/protocol/mysteryvibe.rs +++ b/buttplug/src/server/device/protocol/mysteryvibe.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/mysteryvibe_v2.rs b/buttplug/src/server/device/protocol/mysteryvibe_v2.rs index a662850d..8af8f657 100644 --- a/buttplug/src/server/device/protocol/mysteryvibe_v2.rs +++ b/buttplug/src/server/device/protocol/mysteryvibe_v2.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/nintendo_joycon.rs b/buttplug/src/server/device/protocol/nintendo_joycon.rs index 5638fa1d..35b9beb8 100644 --- a/buttplug/src/server/device/protocol/nintendo_joycon.rs +++ b/buttplug/src/server/device/protocol/nintendo_joycon.rs @@ -1,3 +1,4 @@ +use crate::server::device::configuration::ProtocolCommunicationSpecifier; #[cfg(feature = "wasm")] use crate::util; use crate::{ diff --git a/buttplug/src/server/device/protocol/nobra.rs b/buttplug/src/server/device/protocol/nobra.rs index 2859852c..83352bdf 100644 --- a/buttplug/src/server/device/protocol/nobra.rs +++ b/buttplug/src/server/device/protocol/nobra.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/patoo.rs b/buttplug/src/server/device/protocol/patoo.rs index 8a996fa8..03edddb5 100644 --- a/buttplug/src/server/device/protocol/patoo.rs +++ b/buttplug/src/server/device/protocol/patoo.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, @@ -44,6 +47,7 @@ impl ProtocolIdentifier for PatooIdentifier { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { // Patoo Love devices have wildcarded names of ([A-Z]+)\d* // Force the identifier lookup to the non-numeric portion diff --git a/buttplug/src/server/device/protocol/prettylove.rs b/buttplug/src/server/device/protocol/prettylove.rs index 03a6b749..2461338a 100644 --- a/buttplug/src/server/device/protocol/prettylove.rs +++ b/buttplug/src/server/device/protocol/prettylove.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ @@ -41,6 +44,7 @@ impl ProtocolIdentifier for PrettyLoveIdentifier { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { Ok(( UserDeviceIdentifier::new( diff --git a/buttplug/src/server/device/protocol/satisfyer.rs b/buttplug/src/server/device/protocol/satisfyer.rs index 6bdd8112..717925ab 100644 --- a/buttplug/src/server/device/protocol/satisfyer.rs +++ b/buttplug/src/server/device/protocol/satisfyer.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, @@ -51,7 +54,28 @@ impl ProtocolIdentifier for SatisfyerIdentifier { async fn identify( &mut self, hardware: Arc, + specifier: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { + if let ProtocolCommunicationSpecifier::BluetoothLE(s) = specifier { + for md in s.manufacturer_data().iter() { + if let Some(data) = md.data() { + let device_identifier = format!( + "{}", + u32::from_be_bytes(data.to_vec().try_into().unwrap_or([0; 4])) + ); + info!( + "Satisfyer Device Identifier (from advertisement): {:?} {}", + data, device_identifier + ); + + return Ok(( + UserDeviceIdentifier::new(hardware.address(), "satisfyer", &Some(device_identifier)), + Box::new(SatisfyerInitializer::default()), + )); + } + } + } + let result = hardware .read_value(&HardwareReadCmd::new(Endpoint::RxBLEModel, 128, 500)) .await?; @@ -60,7 +84,7 @@ impl ProtocolIdentifier for SatisfyerIdentifier { u32::from_be_bytes(result.data().to_vec().try_into().unwrap_or([0; 4])) ); info!( - "Satisfyer Device Identifier: {:?} {}", + "Satisfyer Device Identifier (from RxBLEModel): {:?} {}", result.data(), device_identifier ); diff --git a/buttplug/src/server/device/protocol/svakom_avaneo.rs b/buttplug/src/server/device/protocol/svakom_avaneo.rs index 01b0d190..5c5267e6 100644 --- a/buttplug/src/server/device/protocol/svakom_avaneo.rs +++ b/buttplug/src/server/device/protocol/svakom_avaneo.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/svakom_dt250a.rs b/buttplug/src/server/device/protocol/svakom_dt250a.rs index 6236979d..8d28ce3d 100644 --- a/buttplug/src/server/device/protocol/svakom_dt250a.rs +++ b/buttplug/src/server/device/protocol/svakom_dt250a.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/svakom_iker.rs b/buttplug/src/server/device/protocol/svakom_iker.rs index 852542eb..4e8bc807 100644 --- a/buttplug/src/server/device/protocol/svakom_iker.rs +++ b/buttplug/src/server/device/protocol/svakom_iker.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/svakom_sam.rs b/buttplug/src/server/device/protocol/svakom_sam.rs index d98c347d..c2633ea4 100644 --- a/buttplug/src/server/device/protocol/svakom_sam.rs +++ b/buttplug/src/server/device/protocol/svakom_sam.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/svakom_suitcase.rs b/buttplug/src/server/device/protocol/svakom_suitcase.rs index 4640d7e1..38ab110b 100644 --- a/buttplug/src/server/device/protocol/svakom_suitcase.rs +++ b/buttplug/src/server/device/protocol/svakom_suitcase.rs @@ -5,7 +5,10 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/svakom_tarax.rs b/buttplug/src/server/device/protocol/svakom_tarax.rs index 38eac929..d8f3673b 100644 --- a/buttplug/src/server/device/protocol/svakom_tarax.rs +++ b/buttplug/src/server/device/protocol/svakom_tarax.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/svakom_v5.rs b/buttplug/src/server/device/protocol/svakom_v5.rs index 33ef912e..68533764 100644 --- a/buttplug/src/server/device/protocol/svakom_v5.rs +++ b/buttplug/src/server/device/protocol/svakom_v5.rs @@ -7,7 +7,10 @@ use crate::core::message::ActuatorType; use crate::core::message::ActuatorType::{Oscillate, Vibrate}; -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::server::device::hardware::Hardware; use crate::server::device::protocol::ProtocolIdentifier; use crate::server::device::protocol::ProtocolInitializer; diff --git a/buttplug/src/server/device/protocol/thehandy/mod.rs b/buttplug/src/server/device/protocol/thehandy/mod.rs index c12c4cef..35226ba6 100644 --- a/buttplug/src/server/device/protocol/thehandy/mod.rs +++ b/buttplug/src/server/device/protocol/thehandy/mod.rs @@ -8,7 +8,10 @@ use self::handyplug::Ping; use super::fleshlight_launch_helper; -use crate::server::device::configuration::ProtocolDeviceAttributes; +use crate::server::device::configuration::{ + ProtocolCommunicationSpecifier, + ProtocolDeviceAttributes, +}; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/vibcrafter.rs b/buttplug/src/server/device/protocol/vibcrafter.rs index 9db9ffaf..4e87ec5a 100644 --- a/buttplug/src/server/device/protocol/vibcrafter.rs +++ b/buttplug/src/server/device/protocol/vibcrafter.rs @@ -27,6 +27,7 @@ use ecb::cipher::block_padding::Pkcs7; use ecb::cipher::{BlockDecryptMut, BlockEncryptMut, KeyInit}; use std::sync::Arc; +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use rand::distributions::Alphanumeric; use rand::{thread_rng, Rng}; use regex::Regex; diff --git a/buttplug/src/server/device/protocol/vibratissimo.rs b/buttplug/src/server/device/protocol/vibratissimo.rs index 3fca4ac3..b494134a 100644 --- a/buttplug/src/server/device/protocol/vibratissimo.rs +++ b/buttplug/src/server/device/protocol/vibratissimo.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, @@ -43,6 +44,7 @@ impl ProtocolIdentifier for VibratissimoIdentifier { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { let result = hardware .read_value(&HardwareReadCmd::new(Endpoint::RxBLEModel, 128, 500)) diff --git a/buttplug/src/server/device/protocol/vorze_sa.rs b/buttplug/src/server/device/protocol/vorze_sa.rs index 51d5c8de..0aa5905e 100644 --- a/buttplug/src/server/device/protocol/vorze_sa.rs +++ b/buttplug/src/server/device/protocol/vorze_sa.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/wetoy.rs b/buttplug/src/server/device/protocol/wetoy.rs index 47df77de..d4ef1385 100644 --- a/buttplug/src/server/device/protocol/wetoy.rs +++ b/buttplug/src/server/device/protocol/wetoy.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ diff --git a/buttplug/src/server/device/protocol/wevibe.rs b/buttplug/src/server/device/protocol/wevibe.rs index f6fba43d..78b44341 100644 --- a/buttplug/src/server/device/protocol/wevibe.rs +++ b/buttplug/src/server/device/protocol/wevibe.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{ errors::ButtplugDeviceError, diff --git a/buttplug/src/server/device/protocol/youou.rs b/buttplug/src/server/device/protocol/youou.rs index 28e99d28..e99a24fd 100644 --- a/buttplug/src/server/device/protocol/youou.rs +++ b/buttplug/src/server/device/protocol/youou.rs @@ -5,6 +5,7 @@ // Licensed under the BSD 3-Clause license. See LICENSE file in the project root // for full license information. +use crate::server::device::configuration::ProtocolCommunicationSpecifier; use crate::{ core::{errors::ButtplugDeviceError, message::Endpoint}, server::device::{ @@ -43,6 +44,7 @@ impl ProtocolIdentifier for YououIdentifier { async fn identify( &mut self, hardware: Arc, + _: ProtocolCommunicationSpecifier, ) -> Result<(UserDeviceIdentifier, Box), ButtplugDeviceError> { Ok(( UserDeviceIdentifier::new(hardware.address(), "Youou", &Some("VX001_".to_owned())), diff --git a/buttplug/src/server/device/server_device.rs b/buttplug/src/server/device/server_device.rs index 8718fd51..508c6313 100644 --- a/buttplug/src/server/device/server_device.rs +++ b/buttplug/src/server/device/server_device.rs @@ -155,8 +155,9 @@ impl ServerDevice { let mut protocol_identifier_stage = protocol_identifier.unwrap(); let hardware = Arc::new(hardware_out.unwrap()); - let (identifier, mut protocol_initializer) = - protocol_identifier_stage.identify(hardware.clone()).await?; + let (identifier, mut protocol_initializer) = protocol_identifier_stage + .identify(hardware.clone(), hardware_connector.specifier()) + .await?; // Now we have an identifier. After this point, if anything fails, consider it a complete // connection failure, as identify may have already run commands on the device, and therefore