Skip to content

Commit

Permalink
chore: Add retries for Keon/Handy
Browse files Browse the repository at this point in the history
  • Loading branch information
qdot committed Oct 16, 2023
1 parent 8145fe3 commit 1457ad3
Show file tree
Hide file tree
Showing 3 changed files with 25 additions and 0 deletions.
4 changes: 4 additions & 0 deletions buttplug/src/server/device/protocol/kiiroo_v2.rs
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,10 @@ pub struct KiirooV2 {
}

impl ProtocolHandler for KiirooV2 {
fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy {
super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategy
}

fn handle_linear_cmd(
&self,
message: message::LinearCmd,
Expand Down
4 changes: 4 additions & 0 deletions buttplug/src/server/device/protocol/kiiroo_v21_initialized.rs
Original file line number Diff line number Diff line change
Expand Up @@ -67,6 +67,10 @@ pub struct KiirooV21Initialized {
}

impl ProtocolHandler for KiirooV21Initialized {
fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy {
super::ProtocolKeepaliveStrategy::RepeatLastPacketStrategy
}

fn handle_scalar_vibrate_cmd(
&self,
_index: u32,
Expand Down
17 changes: 17 additions & 0 deletions buttplug/src/server/device/protocol/thehandy/mod.rs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// Licensed under the BSD 3-Clause license. See LICENSE file in the project root
// for full license information.

use self::handyplug::Ping;

use super::fleshlight_launch_helper;
use crate::server::device::configuration::ProtocolDeviceAttributes;
use crate::{
Expand Down Expand Up @@ -114,6 +116,21 @@ pub struct TheHandy {
}

impl ProtocolHandler for TheHandy {

fn keepalive_strategy(&self) -> super::ProtocolKeepaliveStrategy {
let ping_payload = handyplug::Payload {
messages: vec![handyplug::Message {
message: Some(handyplug::message::Message::Ping(Ping { id: 999 })),
}]
};
let mut ping_buf = vec![];
ping_payload
.encode(&mut ping_buf)
.expect("Infallible encode.");

super::ProtocolKeepaliveStrategy::RepeatPacketStrategy(HardwareWriteCmd::new(Endpoint::Tx, ping_buf, true))
}

fn handle_fleshlight_launch_fw12_cmd(
&self,
message: message::FleshlightLaunchFW12Cmd,
Expand Down

0 comments on commit 1457ad3

Please sign in to comment.