From e52db1ac8efd9f75f8026be3f42527f9db535c44 Mon Sep 17 00:00:00 2001 From: Anton Palgunov Date: Wed, 8 Jul 2020 14:24:30 +0100 Subject: [PATCH] init --- .gitignore | 1 + Cargo.lock | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++ Cargo.toml | 10 ++++++++++ src/main.rs | 14 ++++++++++++++ 4 files changed, 80 insertions(+) create mode 100644 .gitignore create mode 100644 Cargo.lock create mode 100644 Cargo.toml create mode 100644 src/main.rs diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..ea8c4bf --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +/target diff --git a/Cargo.lock b/Cargo.lock new file mode 100644 index 0000000..fca7b58 --- /dev/null +++ b/Cargo.lock @@ -0,0 +1,55 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +[[package]] +name = "blurz" +version = "0.4.0" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "b1bc2df4d0f1d373b324672d9966aca3f5ba1f03d69edad6240144774539ea59" +dependencies = [ + "dbus", + "hex", +] + +[[package]] +name = "dbus" +version = "0.6.5" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "48b5f0f36f1eebe901b0e6bee369a77ed3396334bf3f09abd46454a576f71819" +dependencies = [ + "libc", + "libdbus-sys", +] + +[[package]] +name = "hex" +version = "0.3.2" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "805026a5d0141ffc30abb3be3173848ad46a1b1664fe632428479619a3644d77" + +[[package]] +name = "libc" +version = "0.2.72" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "a9f8082297d534141b30c8d39e9b1773713ab50fdbe4ff30f750d063b3bfd701" + +[[package]] +name = "libdbus-sys" +version = "0.2.1" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "dc12a3bc971424edbbf7edaf6e5740483444db63aa8e23d3751ff12a30f306f0" +dependencies = [ + "pkg-config", +] + +[[package]] +name = "pkg-config" +version = "0.3.17" +source = "registry+https://github.com/rust-lang/crates.io-index" +checksum = "05da548ad6865900e60eaba7f589cc0783590a92e940c26953ff81ddbab2d677" + +[[package]] +name = "sony-fastconnect" +version = "0.1.0" +dependencies = [ + "blurz", +] diff --git a/Cargo.toml b/Cargo.toml new file mode 100644 index 0000000..49508f5 --- /dev/null +++ b/Cargo.toml @@ -0,0 +1,10 @@ +[package] +name = "sony-fastconnect" +version = "0.1.0" +authors = ["Anton Palgunov "] +edition = "2018" + +# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html + +[dependencies] +blurz = "0.4.0" diff --git a/src/main.rs b/src/main.rs new file mode 100644 index 0000000..40cccb6 --- /dev/null +++ b/src/main.rs @@ -0,0 +1,14 @@ +use blurz::BluetoothSession; +use blurz::BluetoothDevice; + +fn main() { + let path = "/org/bluez/hci0/dev_70_26_05_10_48_04"; + + let session = BluetoothSession::create_session(None).unwrap(); + let device = BluetoothDevice::new(&session, path.to_string()); + + match device.connect(2_000) { + Ok(_) => println!("Connected!"), + Err(e) => println!("Error {}", e) + } +}