I am trying to connect my buttplug to my laptop using buttplug.io. I use the following code, adapted from the examples:
use std::str::FromStr;
use buttplug::client::{ButtplugClient, ButtplugClientEvent};
use buttplug::core::connector::ButtplugInProcessClientConnectorBuilder;
use buttplug::server::device::hardware::communication::btleplug::BtlePlugCommunicationManagerBuilder;
use buttplug::server::ButtplugServerBuilder;
use futures::StreamExt;
use tokio::io::{AsyncBufReadExt, BufReader, stdin};
async fn wait_for_input() -> anyhow::Result<Option<String>> {
Ok(BufReader::new(stdin())
.lines()
.next_line()
.await?)
}
#[tokio::main]
async fn main() -> anyhow::Result<()> {
let server = ButtplugServerBuilder::default()
.name("Buttboost embedded buttplug server")
.comm_manager(BtlePlugCommunicationManagerBuilder::default())
.finish()?;
let connector = ButtplugInProcessClientConnectorBuilder::default()
.server(server)
.finish();
let client = ButtplugClient::new("Buttboost");
client.connect(connector).await?;
let mut events = client.event_stream();
tokio::spawn(async move {
while let Some(event) = events.next().await {
match event {
ButtplugClientEvent::DeviceAdded(device) => {
println!("Device {} Connected!", device.name());
}
ButtplugClientEvent::DeviceRemoved(info) => {
println!("Device {} Removed!", info.name());
}
ButtplugClientEvent::ScanningFinished => {
println!("Device scanning is finished!");
}
other => println!("Other event received: {other:?}"),
}
}
});
println!("Scanning for devices. Press [ENTER] to finish.");
client.start_scanning().await?;
wait_for_input().await?;
println!("Stopping scanning...");
client.stop_scanning().await?;
let devices = client.devices();
if devices.is_empty() {
println!("Found no devices, exiting");
return Ok(());
}
println!("Choose a device by entering its number:");
for (index, device) in devices.iter().enumerate() {
println!("{index} - {}", device.name());
}
let _device = loop {
let Some(Ok(choice)) = wait_for_input().await?.map(|choice| usize::from_str(&choice)) else {
println!("Invalid choice, enter a non-negative integer");
continue;
};
let Some(device) = devices.get(choice) else {
println!("Choice too large, enter a device number from the list above");
continue;
};
break device;
};
Ok(())
}
However, my buttplug is not found. I have used wireshark to capture bluetooth traffic, and it seems like the buttplug does generate some traffic. However, it ends with “insufficient authentication”.
Using the intiface central, while it does find the buttplug in the logs, it does not show it under devices.
If required, I can also send the wireshark capture file.
System info:
Distributor ID: | Ubuntu |
---|---|
Description: | Ubuntu 22.04.1 LTS |
Release: | 22.04 |
Codename: | jammy |
buttplug version: 7.0.1
Here is the pairing request sent my my laptop to the device. The following error package contains only a flag for the error, and no further information. The error package is the last package in the sequence.