-
Hi, Can you show me the totally minimum code for connecting to the RFCOMM dongle? I have a remote MAC address, default port (1) and I'd like to get an RFCOMM stream, on which I will then AsyncRead and AsyncWrite. That's all. |
Beta Was this translation helpful? Give feedback.
Replies: 4 comments 4 replies
-
I am also interested so if you have any progress please let me know. UPDATE: it seems RFCOMM is standard bluetooth and not ble so you can use react-native-bluetooth-classic. |
Beta Was this translation helpful? Give feedback.
-
@surban let session = bluer::Session::new().await?;
let adapter = session.default_adapter().await?;
adapter.set_powered(true).await?; It is compiling fine without it, but then I have: I am asking because I have a series of problems when I need to use a diff --git a/bluer/Cargo.toml b/bluer/Cargo.toml
index 6943adc..644922a 100644
--- a/bluer/Cargo.toml
+++ b/bluer/Cargo.toml
@@ -47,7 +47,7 @@ mesh = ["bluetoothd"]
serde = ["uuid/serde", "dep:serde"]
[dependencies]
-dbus = { version = "0.9", features = ["futures"], optional = true }
+dbus = { version = "0.9", features = ["futures", "vendored"], optional = true }
dbus-tokio = { version = "0.7", optional = true }
dbus-crossroads = { version = "0.5", optional = true }
futures = "0.3" because I am crosscompiling. Then I had to remove those above lines because I have:
Edit: I connected successfully after some attempts :) |
Beta Was this translation helpful? Give feedback.
-
@surban I have problems writing to the Stream with: I discovered that I have this error only when: So I've added this after while stream.as_ref().local_addr()?.addr == bluer::Address::any() {
println!("Waiting for local address...");
tokio::time::sleep(Duration::from_secs(1)).await;
}
println!("Local address: {:?}", stream.as_ref().local_addr()?); This workaround seems to be working. For me it is about 5 seconds, then it is communicating fine. Is it a known "problem"? |
Beta Was this translation helpful? Give feedback.
RFCOMM client and server examples have been added.