bluetooth-serial-port
Rust library for interacting with the Bluetooth stack via RFCOMM channels.
This library currently only works on Linux/BlueZ. You can find it on crates.io.
Cargo.toml:
[]
= "0.2"
Example:
extern crate bluetooth_serial_port;
extern crate mio;
use ;
use ;
use ;
// warning: you really should do some error handling in real code...
// scan for devices
let devices = scan_devices.expect;
if devices.len == 0
// "device.name" is name string ot the device
// "device.addr" is the MAC address of the device
let device = &devices;
println!;
// create and connect the RFCOMM socket
let mut socket = new.unwrap;
socket.connect_rfcomm.unwrap;
// BtSocket implements the `Read` and `Write` traits (they're blocking)
let mut buffer = ;
let num_bytes_read = socket.read.expect;
let num_bytes_written = socket.write.expect;
println!;
// BtSocket also implements `mio::Evented` for async IO
let mut event_loop = new.unwrap;
event_loop.register.expect;
// run event loop with some handler...
event_loop.run.expect;