Buttplug sex toy control library
20
fork

Configure Feed

Select the types of activity you want to include in your feed.

fix: Fix for Svakom Iker

Fixes #431 by both wildcarding the Iker name and using the manufactuerer
data as fallback for matching with CSR4, etc dongles.

authored by

blackspherefollower and committed by
qDot
212eb435 21c8b73e

+87 -5
+14 -1
buttplug/buttplug-device-config/buttplug-device-config.json
··· 3313 3313 "svakom-iker": { 3314 3314 "btle": { 3315 3315 "names": [ 3316 - "Iker" 3316 + "Iker*" 3317 + ], 3318 + "manufacturer-data": [ 3319 + { 3320 + "company": 39, 3321 + "data": [ 3322 + 83, 3323 + 86, 3324 + 65 3325 + ] 3326 + } 3317 3327 ], 3318 3328 "services": { 3319 3329 "0000ffe0-0000-1000-8000-00805f9b34fb": { 3320 3330 "tx": "0000ffe1-0000-1000-8000-00805f9b34fb" 3331 + }, 3332 + "00001800-0000-1000-8000-00805f9b34fb": { 3333 + "rxblemodel": "00002a00-0000-1000-8000-00805f9b34fb" 3321 3334 } 3322 3335 } 3323 3336 },
+6 -1
buttplug/buttplug-device-config/buttplug-device-config.yml
··· 1689 1689 svakom-iker: 1690 1690 btle: 1691 1691 names: 1692 - - Iker 1692 + - Iker* 1693 + manufacturer-data: 1694 + - company: 0x27 1695 + data: [0x53, 0x56, 0x41] 1693 1696 services: 1694 1697 0000ffe0-0000-1000-8000-00805f9b34fb: 1695 1698 tx: 0000ffe1-0000-1000-8000-00805f9b34fb 1699 + 00001800-0000-1000-8000-00805f9b34fb: 1700 + rxblemodel: 00002a00-0000-1000-8000-00805f9b34fb 1696 1701 defaults: 1697 1702 name: Svakom Iker 1698 1703 messages:
+67 -3
buttplug/src/server/device/protocol/svakom_iker.rs
··· 5 5 // Licensed under the BSD 3-Clause license. See LICENSE file in the project root 6 6 // for full license information. 7 7 8 + 9 + use crate::server::device::configuration::ProtocolDeviceAttributes; 8 10 use crate::{ 9 11 core::{ 10 12 errors::ButtplugDeviceError, 11 13 message::{ActuatorType, Endpoint}, 12 14 }, 13 15 server::device::{ 14 - hardware::{HardwareCommand, HardwareWriteCmd}, 15 - protocol::{generic_protocol_setup, ProtocolHandler}, 16 + configuration::ProtocolAttributesType, 17 + hardware::{Hardware, HardwareCommand, HardwareReadCmd, HardwareWriteCmd}, 18 + protocol::{ProtocolHandler, ProtocolIdentifier, ProtocolInitializer}, 19 + ServerDeviceIdentifier, 16 20 }, 17 21 }; 22 + use async_trait::async_trait; 23 + use std::{ 24 + sync::Arc, 25 + }; 18 26 19 - generic_protocol_setup!(SvakomIker, "svakom-iker"); 27 + pub mod setup { 28 + use crate::server::device::protocol::{ProtocolIdentifier, ProtocolIdentifierFactory}; 29 + #[derive(Default)] 30 + pub struct SvakomIkerIdentifierFactory {} 31 + 32 + impl ProtocolIdentifierFactory for SvakomIkerIdentifierFactory { 33 + fn identifier(&self) -> &str { 34 + "svakom-iker" 35 + } 36 + 37 + fn create(&self) -> Box<dyn ProtocolIdentifier> { 38 + Box::new(super::SvakomIkerIdentifier::default()) 39 + } 40 + } 41 + } 42 + 43 + #[derive(Default)] 44 + pub struct SvakomIkerInitializer {} 45 + 46 + #[async_trait] 47 + impl ProtocolIdentifier for SvakomIkerIdentifier { 48 + async fn identify( 49 + &mut self, 50 + hardware: Arc<Hardware>, 51 + ) -> Result<(ServerDeviceIdentifier, Box<dyn ProtocolInitializer>), ButtplugDeviceError> { 52 + let result = hardware 53 + .read_value(&HardwareReadCmd::new(Endpoint::RxBLEModel, 128, 500)) 54 + .await?; 55 + let ident = 56 + String::from_utf8(result.data().to_vec()).unwrap_or_else(|_| hardware.name().to_owned()); 57 + if !ident.contains("Iker") { 58 + return Err(ButtplugDeviceError::ProtocolSpecificError("svakom-iker".to_owned(), "Device is not an Iker".to_owned())); 59 + } 60 + Ok(( 61 + ServerDeviceIdentifier::new( 62 + hardware.address(), 63 + "svakom-iker", 64 + &ProtocolAttributesType::Identifier(ident), 65 + ), 66 + Box::new(SvakomIkerInitializer::default()), 67 + )) 68 + } 69 + } 70 + 71 + #[async_trait] 72 + impl ProtocolInitializer for SvakomIkerInitializer { 73 + async fn initialize( 74 + &mut self, 75 + _: Arc<Hardware>, 76 + _: &ProtocolDeviceAttributes, 77 + ) -> Result<Arc<dyn ProtocolHandler>, ButtplugDeviceError> { 78 + Ok(Arc::new(SvakomIker::default())) 79 + } 80 + } 81 + 82 + #[derive(Default)] 83 + pub struct SvakomIkerIdentifier {} 20 84 21 85 #[derive(Default)] 22 86 pub struct SvakomIker {}