mwylde / rumble Goto Github PK
View Code? Open in Web Editor NEWRust Bluetooth Low Energy (BLE) central module library
License: Apache License 2.0
Rust Bluetooth Low Energy (BLE) central module library
License: Apache License 2.0
I have tried several ways but I am unable to see the local_name for discovered devices. Even with the example provided I run into this issue:
let light = central.peripherals().into_iter()
.find(|p| p.properties().local_name.iter()
.any(|name| name.contains("LEDBlue"))).unwrap();
I tried with both the crate and running the cloned repo .
As I understand it UUID::B128(u8vec) takes a vector of u8 in the reverse order to that displayed. This is confusing an not ergonomic.
for example the code:
let authcharuuid : [u8; 16] = [ 0x67, 0xDF , 0xD1, 0x30, 0x42, 0x16, 0x39, 0x89, 0xE4, 0x11, 0xE9, 0x47, 0x30, 0xEE , 0xE9, 0x47];
println!("UUID:{}", UUID::B128(authcharuuid));
produces the output:
UUID:47:E9:EE:30:47:E9:11:E4:89:39:16:42:30:D1:DF:67
I get this error at line:
rumble-0.3.0/src/bluez/protocol/hci.rs:441:15
Since I think this is about names, this may help diagnose:
#hciconfig hci0 up
#hcitool lescan
LE Scan ...
88:C6:26:62:36:AF
88:C6:26:62:36:AF (unknown)
54:4A:16:2E:38:54 (unknown)
54:4A:16:2E:38:54 Comet Blue
54:4A:16:2E:42:E8 (unknown)
54:4A:16:2E:42:E8 Comet Blue
I wrote this function (mostly inspired by the example):
pub fn search() -> Result<(), failure::Error> {
let manager = Manager::new()?;
let adaptaters = manager.adapters()?;
let mut adaptater = adaptaters.into_iter().nth(0).unwrap();
adaptater = manager.down(&adaptater)?;
adaptater = manager.up(&adaptater)?;
let central = adaptater.connect()?;
println!("Scanning...");
central.start_scan()?;
central.on_event(Box::new(|event| {
match event {
rumble::api::CentralEvent::DeviceDiscovered(device_address) => {
println!("{:?}", device_address);
},
_ => println!("other"),
};
}));
thread::sleep(Duration::from_secs(3));
for p in central.peripherals() {
println!("name: {:?} address: {:?}", p.properties().local_name, p.properties().address);
}
Ok(())
}
And my output is the following:
Scanning...
35:6B:C8:09:09:3E
80:7A:BF:E0:8A:B4
other
F8:3A:59:AF:67:25
07:5A:AE:EC:10:7A
EF:A5:3C:1F:49:16
name: None address: 00:00:00:00:00:00
name: None address: 00:00:00:00:00:00
name: None address: 00:00:00:00:00:00
name: None address: 00:00:00:00:00:00
name: Some("HTC BS B454C4") address: 00:00:00:00:00:00
I don't know if I misuse the library or if this is just a bug but in the meanwhile I guess I will have to workaround by getting the addresses from the events or by using another crate.
EDIT:
Ok so my main issue is that i can't get my program to get connected with my device. For the issue above, I looked at the code and figured out that the address field has nothing to do with the fact that the connection is refused.
I did copy/past the example and replaced the name of my device (which is the OpenBCI_Ganglion board). I get the following output:
found: F2:BC:72:E9:77:FD properties: PeripheralProperties { address: 00:00:00:00:00:00, address_type: Random, local_name: Some("Ganglion-9223"), tx_power_level: None, manufacturer_data: None, discovery_count: 2, has_scan_response: true }, characteristics: {}
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Other("ECONNREFUSED: Connection refused")', libcore/result.rs:1009:5
note: Run with `RUST_BACKTRACE=1` for a backtrace.
for the following code:
pub fn main() {
let manager = Manager::new().unwrap();
// get the first bluetooth adapter
let adapters = manager.adapters().unwrap();
let mut adapter = adapters.into_iter().nth(0).unwrap();
// reset the adapter -- clears out any errant state
adapter = manager.down(&adapter).unwrap();
adapter = manager.up(&adapter).unwrap();
// connect to the adapter
let central = adapter.connect().unwrap();
// start scanning for devices
central.start_scan().unwrap();
// instead of waiting, you can use central.on_event to be notified of
// new devices
thread::sleep(Duration::from_secs(2));
// find the device we're interested in
let light = central.peripherals().into_iter()
.find(|p| p.properties().local_name.iter()
.any(|name| name.contains("Ganglion"))).unwrap();
println!("found: {:?}", light);
// connect to the device
light.connect().unwrap();
println!("connected !");
// discover characteristics
light.discover_characteristics().unwrap();
// find the characteristic we want
let chars = light.characteristics();
let cmd_char = chars.iter().find(|c| c.uuid == UUID::B16(0xFFE9)).unwrap();
// dance party
let mut rng = thread_rng();
for _ in 0..20 {
let color_cmd = vec![0x56, rng.gen(), rng.gen(), rng.gen(), 0x00, 0xF0, 0xAA];
light.command(&cmd_char, &color_cmd).unwrap();
thread::sleep(Duration::from_millis(200));
}
}
Do you see any reason why I get this "Connection Refused" error ? I tried with gatttool and it works perfectly though...
From looking at the progress on the Windows port, it seems like it would be possible to support Core Bluetooth
Using code equivalent to the example file, with the change described in #30 in order to allow connection to be successful. When the code reaches the point of attempting to discover characteristics, it hangs in wait_until_done permanently. The backtrace from GDB is as follows:
`PERIPHERAL:
EA:BC:02:5E:A6:C6 properties: PeripheralProperties { address: EA:BC:02:5E:A6:C6, address_type: Random, local_name: Some("LOCK-INIT"), tx_power_level: None, manufacturer_data: Some([2, 162, 255, 255, 255, 253, 5, 71, 147, 2, 0, 0, 0, 205, 4]), discovery_count: 16, has_scan_response: false }, characteristics: {}
[New Thread 0x769ff400 (LWP 14289)]
Trying to discover characteristics...
^C
Thread 1 "hello_world" received signal SIGINT, Interrupt.
0x76f719a4 in __pthread_cond_wait (cond=0x51fe28, mutex=0x51fe08) at pthread_cond_wait.c:188
188 pthread_cond_wait.c: No such file or directory.
(gdb) bt
#0 0x76f719a4 in __pthread_cond_wait (cond=0x51fe28, mutex=0x51fe08) at pthread_cond_wait.c:188
#1 0x00460784 in std::sys::unix::condvar::Condvar::wait::hd4783c7e53c7894c (self=0x51fe28, mutex=0x51fe08)
at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libstd/sys/unix/condvar.rs:69
#2 0x004236cc in std::sys_common::condvar::Condvar::wait::h1834f96141448671 (self=0x51fe28, mutex=0x51fe08)
at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libstd/sys_common/condvar.rs:41
#3 0x00459228 in std::sync::condvar::Condvar::wait::hb2f047c82f3cfd71 (self=0x51fe90, guard=...)
at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libstd/sync/condvar.rs:204
#4 0x0047bb74 in rumble::bluez::adapter::peripheral::Peripheral::wait_until_done::h02e167200bfd64a3 (operation=...)
at /home/josh/.cargo/git/checkouts/rumble-909815939d4a9900/3117372/src/bluez/adapter/peripheral.rs:289
#5 0x0047b848 in rumble::bluez::adapter::peripheral::Peripheral::request_raw::he3462da61a8e24b0 (self=0x7efff168, data=...)
at /home/josh/.cargo/git/checkouts/rumble-909815939d4a9900/3117372/src/bluez/adapter/peripheral.rs:208
#6 0x0047e048 in _$LT$rumble..bluez..adapter..peripheral..Peripheral$u20$as$u20$rumble..api..Peripheral$GT$::discover_characteristics_in_range::h5b974183dd98d25e (self=0x7efff168, start=1, end=65535)
at /home/josh/.cargo/git/checkouts/rumble-909815939d4a9900/3117372/src/bluez/adapter/peripheral.rs:454
#7 0x0047dd64 in $LT$rumble..bluez..adapter..peripheral..Peripheral$u20$as$u20$rumble..api..Peripheral$GT$::discover_characteristics::h156ac34c88075480 (self=0x7efff168)
at /home/josh/.cargo/git/checkouts/rumble-909815939d4a9900/3117372/src/bluez/adapter/peripheral.rs:444
#8 0x00407240 in hello_world::main::h84896516970ce619 () at src/main.rs:46
#9 0x00408e08 in std::rt::lang_start::
at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libstd/rt.rs:64
#10 0x004df3e4 in {{closure}} () at src/libstd/rt.rs:49
#11 do_call<closure,i32> () at src/libstd/panicking.rs:293
#12 0x004e2678 in __rust_maybe_catch_panic () at src/libpanic_unwind/lib.rs:87
#13 0x004dfe38 in try<i32,closure> () at src/libstd/panicking.rs:272
#14 catch_unwind<closure,i32> () at src/libstd/panic.rs:388
#15 lang_start_internal () at src/libstd/rt.rs:48
#16 0x00408dd8 in std::rt::lang_start::h14f3dad8e1b8c801 (main=0x406d70 <hello_world::main::h84896516970ce619>, argc=1,
argv=0x7efff764) at /rustc/3c235d5600393dfe6c36eeed34042efad8d4f26e/src/libstd/rt.rs:64
#17 0x00407648 in main ()
`
This library looks really promising, I would love to hear back on this about how a fix may be possible. Info on vars in the most relevant frames is follows, I can capture more debug output on request,
including output from my peripheral, which currently outputs nothing of relevance during the wait.
(gdb) frame 4 #4 0x0047bb74 in rumble::bluez::adapter::peripheral::Peripheral::wait_until_done::h02e167200bfd64a3 (operation=...) at /home/josh/.cargo/git/checkouts/rumble-909815939d4a9900/3117372/src/bluez/adapter/peripheral.rs:289 289 done = cvar.wait(done).unwrap(); (gdb) locals Undefined command: "locals". Try "help". (gdb) info locals done = std::sync::mutex::MutexGuard<core::option::Option<core::result::Result<alloc::vec::Vec<u8>, rumble::Error>>> {__lock: 0x51fe68, __poison: std::sys_common::poison::Guard {panicking: false}} lock = 0x51fe68 cvar = 0x51fe90 on_finish = 0x51fea0 pair2 = alloc::sync::Arc<(std::sync::mutex::Mutex<core::option::Option<core::result::Result<alloc::vec::Vec<u8>, rumble::Error>>>, std::sync::condvar::Condvar)> {ptr: core::ptr::NonNull<alloc::sync::ArcInner<(std::sync::mutex::Mutex<core::option::Option<core::result::Result<alloc::vec::Vec<u8>, rumble::Error>>>, std::sync::condvar::Condvar)>> {pointer: 0x51fe60}, phantom: core::marker::PhantomData<(std::sync::mutex::Mutex<core::option::Option<core::result::Result<alloc::vec::Vec<u8>, rumble::Error>>>, std::sync::condvar::Condvar)>} pair = alloc::sync::Arc<(std::sync::mutex::Mutex<core::option::Option<core::result::Result<alloc::vec::Vec<u8>, rumble::Error>>>, std::sync::condvar::Condvar)> {ptr: core::ptr::NonNull<alloc::sync::ArcInner<(std::sync::mutex::Mutex<core::option::Option<core::result::Result<alloc::vec::Vec<u8>, rumble::Error>>>, std::sync::condvar::Condvar)>> {pointer: 0x51fe60}, phantom: core::marker::PhantomData<(std::sync::mutex::Mutex<core::option::Option<core::result::Result<alloc::vec::Vec<u8>, rumble::Error>>>, std::sync::condvar::Condvar)>} (gdb) frame 6 #6 0x0047e048 in _$LT$rumble..bluez..adapter..peripheral..Peripheral$u20$as$u20$rumble..api..Peripheral$GT$::discover_characteristics_in_range::h5b974183dd98d25e (self=0x7efff168, start=1, end=65535) at /home/josh/.cargo/git/checkouts/rumble-909815939d4a9900/3117372/src/bluez/adapter/peripheral.rs:454 454 let data = self.request_raw(&mut buf)?; (gdb) info locals buf = alloc::vec::Vec<u8> {buf: alloc::raw_vec::RawVec<u8, alloc::alloc::Global> {ptr: core::ptr::Unique<u8> {pointer: 0x51fb28 "\b\001\000", _marker: core::marker::PhantomData<u8>}, cap: 7, a: alloc::alloc::Global}, len: 7} start = 1 results = alloc::vec::Vec<rumble::api::Characteristic> {buf: alloc::raw_vec::RawVec<rumble::api::Characteristic, alloc::alloc::Global> {ptr: core::ptr::Unique<rumble::api::Characteristic> {pointer: 0x2, _marker: core::marker::PhantomData<rumble::api::Characteristic>}, cap: 0, a: alloc::alloc::Global}, len: 0} (gdb) frame 7 #7 0x0047dd64 in _$LT$rumble..bluez..adapter..peripheral..Peripheral$u20$as$u20$rumble..api..Peripheral$GT$::discover_characteristics::h156ac34c88075480 (self=0x7efff168) at /home/josh/.cargo/git/checkouts/rumble-909815939d4a9900/3117372/src/bluez/adapter/peripheral.rs:444 444 self.discover_characteristics_in_range(0x0001, 0xFFFF) (gdb) info locals No locals.
I don't know it that's the right issue, but my peripheral device accepts connections without pairing, and complains if you actually want to pair.
I can connect to the device using bluetoothctl and everything works as expected, but when I try to connect with the code from the example (where only the name has been changed), it does not work. It tries to connect (it blocks) then it panics with an "operation in process" error message.
What could be the next steps to debug the issue?
I'm thinking it might be related to pairing as I also tried to connect with blurz and it works with that crate when I just connect - without pairing - to the device. Looking at your code on connect it does not look like you are trying to pair though...
Hi! Iโm a Rust noob so forgive me:
If I follow the advice in the example and try to convert to on_event
, I end up with something like:
central.start_scan().unwrap();
central.on_event(Box::new(|e: CentralEvent| match e {
CentralEvent::DeviceDiscovered(addr) => {
central.peripheral(addr).map(|lamp| {
lamp.connect().unwrap();
...
});
},
_ => {},
}));
// end of main()
Which results in
error[E0597]: `central` does not live long enough
--> src/main.rs:38:13
|
36 | central.on_event(Box::new(|e: CentralEvent| match e {
| - ----------------- value captured here
| ______________________|
| |
37 | | CentralEvent::DeviceDiscovered(addr) => {
38 | | central.peripheral(addr).map(|lamp| {
| | ^^^^^^^ borrowed value does not live long enough
39 | | lamp.connect().unwrap();
... |
55 | | _ => {},
56 | | }));
| |______- cast requires that `central` is borrowed for `'static`
57 | }
| - `central` dropped here while still borrowed
How do I correctly box this?
Hi there,
Full disclosure, I'm rust newbie.
I tried to compile rumble example on my Fedora 27 and I have this error:
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Sys(ENODEV)', /checkout/src/libcore/result.rs:916:5
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at /checkout/src/libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at /checkout/src/libstd/sys_common/backtrace.rs:68
at /checkout/src/libstd/sys_common/backtrace.rs:57
2: std::panicking::default_hook::{{closure}}
at /checkout/src/libstd/panicking.rs:381
3: std::panicking::default_hook
at /checkout/src/libstd/panicking.rs:397
4: std::panicking::rust_panic_with_hook
at /checkout/src/libstd/panicking.rs:577
5: std::panicking::begin_panic
at /checkout/src/libstd/panicking.rs:538
6: std::panicking::begin_panic_fmt
at /checkout/src/libstd/panicking.rs:522
7: rust_begin_unwind
at /checkout/src/libstd/panicking.rs:498
8: core::panicking::panic_fmt
at /checkout/src/libcore/panicking.rs:71
9: core::result::unwrap_failed
at /checkout/src/libcore/macros.rs:23
10: <core::result::Result<T, E>>::unwrap
at /checkout/src/libcore/result.rs:782
11: mimux::main
at src/main.rs:13
12: std::rt::lang_start::{{closure}}
at /checkout/src/libstd/rt.rs:74
13: std::panicking::try::do_call
at /checkout/src/libstd/rt.rs:59
at /checkout/src/libstd/panicking.rs:480
14: __rust_maybe_catch_panic
at /checkout/src/libpanic_unwind/lib.rs:101
15: std::rt::lang_start_internal
at /checkout/src/libstd/panicking.rs:459
at /checkout/src/libstd/panic.rs:365
at /checkout/src/libstd/rt.rs:58
16: std::rt::lang_start
at /checkout/src/libstd/rt.rs:74
17: main
18: __libc_start_main
19: _start
Any tips?
Thanks! ๐
I'm trying to use this crate to control some light bulbs with my wireless router through SSH. My wireless router currently runs OpenWRT which uses Musl as default library. However, I'm facing some problems trying to compile the current version using the target triple "mips-unknown-linux-musl":
error[E0425]: cannot find value `SOL_BLUETOOTH` in module `libc`
--> /home/leonardohn/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/adapter/peripheral.rs:348:40
|
348 | libc::setsockopt(fd, libc::SOL_BLUETOOTH, 4, opt.as_mut_ptr() as *mut libc::c_void, 2)
| ^^^^^^^^^^^^^ did you mean `AF_BLUETOOTH`?
error[E0308]: mismatched types
--> /home/leonardohn/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/manager/mod.rs:75:35
|
75 | libc::ioctl(*ctl, HCI_GET_DEV_LIST_MAGIC as libc::c_ulong, dl as (*mut c_void)))?;
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32
error[E0308]: mismatched types
--> /home/leonardohn/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/adapter/mod.rs:468:43
|
468 | handle_error(libc::ioctl(ctl, HCI_GET_DEV_MAGIC as libc::c_ulong,
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected i32, found u32
error: aborting due to 3 previous errors
Some errors occurred: E0308, E0425.
For more information about an error, try `rustc --explain E0308`.
error: Could not compile `rumble`.
When I try to compile to my computer architecture it works fine, so, the problem seems to be with using Musl instead of Glibc.
By the way, I'm currently using rust standard library with the project, but it would be nice to move to no_std as it could save some space into the binary file, considering my router has only 8mb in space.
Are you planning to support Musl and no_std implementations?
As much as I really don't want to do this, I'm getting the feeling that rumble has been abandoned, so:
I've forked rumble over to https://github.com/deviceplug/btleplug
We need an updated library version to update https://github.com/buttplugio/buttplug-rs on crates.io. I've brought in a few of the pull requests here, as well as building out our own patches to fix up WinRT support, and will be starting MacOS CoreBluetooth support soon (Update: As of 0.4.0 we now have Linux/MacOS/Windows 10 UWP).
My plans include:
I will reiterate that I really don't want to do this (I seriously do not have time to support a full Bluetooth library), but this is the Rust library with the most development on it so far and I'd really rather not start from scratch. I'm not doing this out of animosity by any means, and am completely up for sharing patches or un-forking if that becomes an option. I'll be keeping the licenses MIT/Apache, and excluding this from the other licensing/CLA requirements of the other orgs I run.
If anyone wants to help out, or there are any objections, please let me know.
I am a newbie with rust. I would like to a sample/example of writing to a BLE characteristics with notify. I really appreciate if someone is kind enough give me a helping hand. Thank you,
First: Thank you for this library, this is what got me into Rust programming!
When I start my light bulb control I get no panics.
Usually that is. But if I let it run for a couple of hours, at one point it panics with the following log (which prints a lot of words twice for some reason):
thread 'thread '<unnamed><unnamed>' panicked at '' panicked at 'attempt to subtract with overflowattempt to subtract with overflow', ', /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec8
23/rumble-0.2.1/src/bluez/protocol/hci.rs/home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/protocol/hci.rs::442442::1515
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
stack backtrace:
0: std::sys::unix::backtrace::tracing::imp::unwind_backtrace
at libstd/sys/unix/backtrace/tracing/gcc_s.rs:49
1: std::sys_common::backtrace::print
at libstd/sys_common/backtrace.rs:71
at libstd/sys_common/backtrace.rs:59
2: std::panicking::default_hook::{{closure}}
at libstd/panicking.rs:211
3: std::panicking::default_hook
at libstd/panicking.rs:227
4: std::panicking::rust_panic_with_hook
at libstd/panicking.rs:476
5: std::panicking::continue_panic_fmt
at libstd/panicking.rs:390
6: rust_begin_unwind
at libstd/panicking.rs:325
7: core::panicking::panic_fmt
at libcore/panicking.rs:77
8: core::panicking::panic
at libcore/panicking.rs:52
9: rumble::bluez::protocol::hci::le_advertising_data
at /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/protocol/hci.rs:442
10: rumble::bluez::protocol::hci::le_advertising_info
at /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/<::nom::macros::named macros>:13
11: rumble::bluez::protocol::hci::le_meta_event
at /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/protocol/hci.rs:586
12: rumble::bluez::protocol::hci::hci_event_pkt
at /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/protocol/hci.rs:659
13: rumble::bluez::protocol::hci::message
at /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/protocol/hci.rs:740
14: rumble::bluez::adapter::ConnectedAdapter::add_raw_socket_reader::{{closure}}
at /home/pi/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.2.1/src/bluez/adapter/mod.rs:256
note: Some details are omitted, run with `RUST_BACKTRACE=full` for a verbose backtrace.
The bug seems to happen in this line:
rumble/src/bluez/protocol/hci.rs
Line 441 in 889bdca
I'd really appreciate any help on narrowing this bug down. This is my first Rust project so I don't know too many debugging tips.
Cheers!
If not, what can I do to help support it?
It looks like there aren't any Rust libraries that support acting as a peripheral yet.
Ocassionally from time to time when calling Peripheral connect() methon I'm getting panic
thread 'main' panicked at 'called
Result::unwrap()on an
Err value: Other("ENOSYS: Function not implemented")', libcore/result.rs:1009:5
I'm not unwrapping anything:
match periph.connect() {
Ok(_) => info!("Connected ! .."),
Err(e) => {
info!("Unable to connect !:{}", e);
process::exit(-1);
}
}
It looks like some error from undelying libc* bindings ..?
Hello,
I'm trying to compile the example provided in the README.
My Cargo.toml
is fairly innocuous:
[package]
name = "bt-test"
version = "0.1.0"
authors = ["Will Brickner <[email protected]>"]
edition = "2018"
[dependencies]
rumble = "0.3.0"
cargo build --verbose
when depending on rumble
0.3.0
:Compiling rumble v0.3.0
Running `rustc --crate-name rumble /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=ac1a4dbede5ee02c -C extra-filename=-ac1a4dbede5ee02c --out-dir /Users/wbrickner/Documents/Projects/bt-test/target/debug/deps -L dependency=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps --extern backtrace=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbacktrace-02ed44e55d12d8a2.rmeta --extern bitflags=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbitflags-97d8e3b592ae20b2.rmeta --extern bytes=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbytes-bd634047ae16299d.rmeta --extern enum_primitive=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libenum_primitive-2a3edeae187f21c6.rmeta --extern failure=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libfailure-fe875981978b951c.rmeta --extern failure_derive=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libfailure_derive-0e009d037b06b26d.dylib --extern libc=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/liblibc-0da72605b49ff281.rmeta --extern log=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/liblog-c6d198338ecce15c.rmeta --extern nix=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnix-6060188ab1045507.rmeta --extern nom=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnom-037df20ac009f6e9.rmeta --extern num=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnum-da71659f29e11d78.rmeta --cap-lints allow`
error[E0432]: unresolved import `libc::AF_BLUETOOTH`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/manager/mod.rs:6:22
|
6 | use libc::{SOCK_RAW, AF_BLUETOOTH};
| ^^^^^^^^^^^^ no `AF_BLUETOOTH` in the root
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/peripheral.rs:298:30
|
298 | l2_family: libc::AF_BLUETOOTH as libc::sa_family_t,
| ^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `SOL_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/peripheral.rs:315:40
|
315 | libc::setsockopt(fd, libc::SOL_BLUETOOTH, 4, opt.as_mut_ptr() as *mut libc::c_void, 2)
| ^^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/peripheral.rs:320:30
|
320 | l2_family: libc::AF_BLUETOOTH as u16,
| ^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/peripheral.rs:389:32
|
389 | libc::socket(libc::AF_BLUETOOTH, libc::SOCK_SEQPACKET, 0)
| ^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/mod.rs:181:32
|
181 | libc::socket(libc::AF_BLUETOOTH, libc::SOCK_RAW | libc::SOCK_CLOEXEC, 1)
| ^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `SOCK_CLOEXEC` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/mod.rs:181:69
|
181 | libc::socket(libc::AF_BLUETOOTH, libc::SOCK_RAW | libc::SOCK_CLOEXEC, 1)
| ^^^^^^^^^^^^ help: a constant with a similar name exists: `O_CLOEXEC`
|
::: /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.81/src/unix/bsd/apple/mod.rs:1407:1
|
1407 | pub const O_CLOEXEC: ::c_int = 0x1000000;
| ----------------------------------------- similarly named constant `O_CLOEXEC` defined here
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/mod.rs:185:31
|
185 | hci_family: libc::AF_BLUETOOTH as u16,
| ^^^^^^^^^^^^ not found in `libc`
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0425, E0432.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `rumble`
Caused by:
process didn't exit successfully: `rustc --crate-name rumble /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=ac1a4dbede5ee02c -C extra-filename=-ac1a4dbede5ee02c --out-dir /Users/wbrickner/Documents/Projects/bt-test/target/debug/deps -L dependency=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps --extern backtrace=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbacktrace-02ed44e55d12d8a2.rmeta --extern bitflags=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbitflags-97d8e3b592ae20b2.rmeta --extern bytes=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbytes-bd634047ae16299d.rmeta --extern enum_primitive=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libenum_primitive-2a3edeae187f21c6.rmeta --extern failure=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libfailure-fe875981978b951c.rmeta --extern failure_derive=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libfailure_derive-0e009d037b06b26d.dylib --extern libc=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/liblibc-0da72605b49ff281.rmeta --extern log=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/liblog-c6d198338ecce15c.rmeta --extern nix=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnix-6060188ab1045507.rmeta --extern nom=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnom-037df20ac009f6e9.rmeta --extern num=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnum-da71659f29e11d78.rmeta --cap-lints allow` (exit code: 1)
rumble
0.2.0
yields similar results: Compiling rumble v0.3.0
Running `rustc --crate-name rumble /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=ac1a4dbede5ee02c -C extra-filename=-ac1a4dbede5ee02c --out-dir /Users/wbrickner/Documents/Projects/bt-test/target/debug/deps -L dependency=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps --extern backtrace=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbacktrace-02ed44e55d12d8a2.rmeta --extern bitflags=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbitflags-97d8e3b592ae20b2.rmeta --extern bytes=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbytes-bd634047ae16299d.rmeta --extern enum_primitive=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libenum_primitive-2a3edeae187f21c6.rmeta --extern failure=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libfailure-fe875981978b951c.rmeta --extern failure_derive=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libfailure_derive-0e009d037b06b26d.dylib --extern libc=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/liblibc-0da72605b49ff281.rmeta --extern log=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/liblog-c6d198338ecce15c.rmeta --extern nix=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnix-6060188ab1045507.rmeta --extern nom=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnom-037df20ac009f6e9.rmeta --extern num=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnum-da71659f29e11d78.rmeta --cap-lints allow`
error[E0432]: unresolved import `libc::AF_BLUETOOTH`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/manager/mod.rs:6:22
|
6 | use libc::{SOCK_RAW, AF_BLUETOOTH};
| ^^^^^^^^^^^^ no `AF_BLUETOOTH` in the root
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/peripheral.rs:298:30
|
298 | l2_family: libc::AF_BLUETOOTH as libc::sa_family_t,
| ^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `SOL_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/peripheral.rs:315:40
|
315 | libc::setsockopt(fd, libc::SOL_BLUETOOTH, 4, opt.as_mut_ptr() as *mut libc::c_void, 2)
| ^^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/peripheral.rs:320:30
|
320 | l2_family: libc::AF_BLUETOOTH as u16,
| ^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/peripheral.rs:389:32
|
389 | libc::socket(libc::AF_BLUETOOTH, libc::SOCK_SEQPACKET, 0)
| ^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/mod.rs:181:32
|
181 | libc::socket(libc::AF_BLUETOOTH, libc::SOCK_RAW | libc::SOCK_CLOEXEC, 1)
| ^^^^^^^^^^^^ not found in `libc`
error[E0425]: cannot find value `SOCK_CLOEXEC` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/mod.rs:181:69
|
181 | libc::socket(libc::AF_BLUETOOTH, libc::SOCK_RAW | libc::SOCK_CLOEXEC, 1)
| ^^^^^^^^^^^^ help: a constant with a similar name exists: `O_CLOEXEC`
|
::: /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/libc-0.2.81/src/unix/bsd/apple/mod.rs:1407:1
|
1407 | pub const O_CLOEXEC: ::c_int = 0x1000000;
| ----------------------------------------- similarly named constant `O_CLOEXEC` defined here
error[E0425]: cannot find value `AF_BLUETOOTH` in crate `libc`
--> /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/bluez/adapter/mod.rs:185:31
|
185 | hci_family: libc::AF_BLUETOOTH as u16,
| ^^^^^^^^^^^^ not found in `libc`
error: aborting due to 8 previous errors
Some errors have detailed explanations: E0425, E0432.
For more information about an error, try `rustc --explain E0425`.
error: could not compile `rumble`
Caused by:
process didn't exit successfully: `rustc --crate-name rumble /Users/wbrickner/.cargo/registry/src/github.com-1ecc6299db9ec823/rumble-0.3.0/src/lib.rs --error-format=json --json=diagnostic-rendered-ansi --crate-type lib --emit=dep-info,metadata,link -C embed-bitcode=no -C debuginfo=2 -C metadata=ac1a4dbede5ee02c -C extra-filename=-ac1a4dbede5ee02c --out-dir /Users/wbrickner/Documents/Projects/bt-test/target/debug/deps -L dependency=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps --extern backtrace=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbacktrace-02ed44e55d12d8a2.rmeta --extern bitflags=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbitflags-97d8e3b592ae20b2.rmeta --extern bytes=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libbytes-bd634047ae16299d.rmeta --extern enum_primitive=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libenum_primitive-2a3edeae187f21c6.rmeta --extern failure=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libfailure-fe875981978b951c.rmeta --extern failure_derive=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libfailure_derive-0e009d037b06b26d.dylib --extern libc=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/liblibc-0da72605b49ff281.rmeta --extern log=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/liblog-c6d198338ecce15c.rmeta --extern nix=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnix-6060188ab1045507.rmeta --extern nom=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnom-037df20ac009f6e9.rmeta --extern num=/Users/wbrickner/Documents/Projects/bt-test/target/debug/deps/libnum-da71659f29e11d78.rmeta --cap-lints allow` (exit code: 1)
macOS Big Sur v11.1
. Running rustup show
yieldsrustup show
Default host: x86_64-apple-darwin
rustup home: /Users/wbrickner/.rustup
installed toolchains
--------------------
stable-x86_64-apple-darwin
nightly-x86_64-apple-darwin (default)
nightly-x86_64-unknown-linux-gnu
installed targets for active toolchain
--------------------------------------
aarch64-apple-ios
aarch64-linux-android
armv7-linux-androideabi
i686-linux-android
thumbv7em-none-eabi
thumbv7em-none-eabihf
thumbv7m-none-eabi
x86_64-apple-darwin
x86_64-apple-ios
x86_64-linux-android
x86_64-unknown-linux-musl
active toolchain
----------------
nightly-x86_64-apple-darwin (default)
rustc 1.51.0-nightly (0b644e419 2020-12-26)
Really interested in rumble
, hopefully we can get it to compile ๐ .
Hi all,
Ubuntu 18.04.2 LTS (Bionic Beaver)
Linux 4.15.0-47-generic #50-Ubuntu SMP Wed Mar 13 10:44:52 UTC 2019 x86_64 x86_64 x86_64 GNU/Linux
dmesg | grep -i bluetooth
[ 2.750304] Bluetooth: Core ver 2.22
[ 2.750318] Bluetooth: HCI device and connection manager initialized
[ 2.750320] Bluetooth: HCI socket layer initialized
[ 2.750322] Bluetooth: L2CAP socket layer initialized
[ 2.750326] Bluetooth: SCO socket layer initialized
[ 2.771778] Bluetooth: hci0: using rampatch file: qca/rampatch_usb_00000302.bin
[ 2.771780] Bluetooth: hci0: QCA: patch rome 0x302 build 0x3e8, firmware rome 0x302 build 0x111
[ 2.851976] Bluetooth: hci0: using NVM file: qca/nvm_usb_00000302.bin
[ 4.933220] Bluetooth: BNEP (Ethernet Emulation) ver 1.3
[ 4.933221] Bluetooth: BNEP filters: protocol multicast
[ 4.933223] Bluetooth: BNEP socket layer initialized
[ 21.849736] Bluetooth: RFCOMM TTY layer initialized
[ 21.849741] Bluetooth: RFCOMM socket layer initialized
[ 21.849744] Bluetooth: RFCOMM ver 1.11
With this code:
extern crate rumble;
extern crate rand;
use std::thread;
use std::time::Duration;
use rand::{Rng, thread_rng};
use rumble::bluez::manager::Manager;
use rumble::api::{UUID, Central, Peripheral};
pub fn main() {
let manager = Manager::new().unwrap();
// get the first bluetooth adapter
let adapters = manager.adapters().unwrap();
let mut adapter = adapters.into_iter().nth(0).unwrap();
// reset the adapter -- clears out any errant state
adapter = manager.down(&adapter).unwrap();
adapter = manager.up(&adapter).unwrap();
// connect to the adapter
let central = adapter.connect().unwrap();
// start scanning for devices
central.start_scan().unwrap();
// instead of waiting, you can use central.on_event to be notified of
// new devices
thread::sleep(Duration::from_secs(2));
// find the device we're interested in
let sphero_mini = central.peripherals().into_iter()
.find(|p| p.properties().local_name.iter()
.any(|name| name.contains("SM-"))).unwrap();
println!("{:?}", sphero_mini);
// connect to the device
sphero_mini.connect().unwrap();
println!("Is sphero connected: {:?}", sphero_mini.is_connected());
// discover characteristics
sphero_mini.discover_characteristics().unwrap();
// find the characteristic we want
let chars = sphero_mini.characteristics();
for c in chars {
println!("{:?}", c);
}
}
I have this message:
$ ./test
C1:44:3B:21:3D:9C properties: PeripheralProperties { address: C1:44:3B:21:3D:9C, address_type: Random, local_name: Some("SM-3D9C"), tx_power_level: None, manufacturer_data: None, discovery_count: 2, has_scan_response: true }, characteristics: {}
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: Other("ECONNREFUSED: Connection refused")', src/libcore/result.rs:997:5
note: Run with `RUST_BACKTRACE=1` environment variable to display a backtrace.
If I write same code in Javascript using noble
, it's working.
The difference is l2_bdaddr_type
value.
Rumble
set to 1 (BDADDR_LE_PUBLIC
) where Noble
set to 2 (BDADDR_LE_RANDOM
).
In peripheral.rs
file if I change:
let addr = SockaddrL2 {
l2_family: libc::AF_BLUETOOTH as u16,
l2_psm: 0,
l2_bdaddr: self.address,
l2_cid: ATT_CID,
l2_bdaddr_type: 1,
};
to
let addr = SockaddrL2 {
l2_family: libc::AF_BLUETOOTH as u16,
l2_psm: 0,
l2_bdaddr: self.address,
l2_cid: ATT_CID,
l2_bdaddr_type: 2,
};
It's work nice.
C1:44:3B:21:3D:9C properties: PeripheralProperties { address: C1:44:3B:21:3D:9C, address_type: Random, local_name: Some("SM-3D9C"), tx_power_level: None, manufacturer_data: None, discovery_count: 7, has_scan_response: false }, characteristics: {}
SockaddrL2 { l2_family: 31, l2_psm: 0, l2_bdaddr: 9C:B6:D0:E7:F3:64, l2_cid: 4, l2_bdaddr_type: 0 }
Bind socket ok
Cfg socket ok
Connect socket ok
Is sphero connected: true
Characteristic { start_handle: 2, end_handle: 65535, value_handle: 3, uuid: 2A:00, properties: READ }
Characteristic { start_handle: 4, end_handle: 65535, value_handle: 5, uuid: 2A:01, properties: READ }
Characteristic { start_handle: 6, end_handle: 65535, value_handle: 7, uuid: 2A:04, properties: READ }
Characteristic { start_handle: 9, end_handle: 65535, value_handle: 10, uuid: 2A:05, properties: INDICATE }
Characteristic { start_handle: 13, end_handle: 65535, value_handle: 14, uuid: 00:02:00:03:57:4F:4F:20:53:70:68:65:72:6F:21:21, properties: WRITE_WITHOUT_RESPONSE }
Characteristic { start_handle: 15, end_handle: 65535, value_handle: 16, uuid: 00:02:00:02:57:4F:4F:20:53:70:68:65:72:6F:21:21, properties: WRITE | NOTIFY }
Characteristic { start_handle: 18, end_handle: 65535, value_handle: 19, uuid: 00:02:00:04:57:4F:4F:20:53:70:68:65:72:6F:21:21, properties: READ }
Characteristic { start_handle: 20, end_handle: 65535, value_handle: 21, uuid: 00:02:00:05:57:4F:4F:20:53:70:68:65:72:6F:21:21, properties: WRITE_WITHOUT_RESPONSE | WRITE }
Characteristic { start_handle: 23, end_handle: 65535, value_handle: 24, uuid: 2A:19, properties: READ | NOTIFY }
Characteristic { start_handle: 27, end_handle: 65535, value_handle: 28, uuid: 00:01:00:02:57:4F:4F:20:53:70:68:65:72:6F:21:21, properties: WRITE_WITHOUT_RESPONSE | WRITE | NOTIFY }
Characteristic { start_handle: 30, end_handle: 65535, value_handle: 31, uuid: 00:01:00:03:57:4F:4F:20:53:70:68:65:72:6F:21:21, properties: WRITE_WITHOUT_RESPONSE | WRITE | NOTIFY }
Regards,
I tried to run the example given in the documentation on a Raspberry Pi W zero running Raspbian OS.
The code produces a PermissionDenied exception at
adapter = manager.down(&adapter).unwrap();
I have the raspberry's bluetooth interface turned On, with discoverable mode turned On and pairable mode turned On.
Hi,
I have an app that is working as a daemon and after acquiring adapter is making queries then sleeps and make ble operations again.
Afer some time there is a lot open sockets and after few hours apps crashes due to exausting system resources. After few hours.
xiaomi-se 11289 root 524u sock 0,9 0t0 1009087 protocol: HCI
xiaomi-se 11289 root 525u sock 0,9 0t0 1009088 protocol: L2CAP
xiaomi-se 11289 root 526u sock 0,9 0t0 1010309 protocol: HCI
xiaomi-se 11289 root 527u sock 0,9 0t0 1010312 protocol: L2CAP
root@fx160:/proc/11289# lsof -n -p 11289|less|grep L2CAP|wc -l
198
root@fx160:/proc/11289# lsof -n -p 11289|less|grep HCI|wc -l
297
Code is basic:
There is function returning available adapter that is then used in a loop:
// return running ble interface
fn prepare_ble_interface() -> rumble::bluez::adapter::Adapter
// inside main()
let ble_iface = prepare_ble_interface();
loop {
// make ble queries using ble_iface
//sleep for some time
}
I've tried to call prepare_ble_interface() outside loop and within where it should be deallocated every iteration. No changes. Until program is running number of open BLE sockets is increasing with every connection to ble device.
I've been trying to use Rumble to pull in data from BLE beacons but I'm running into some issues where the API doesn't seem suited for them. Beacons are BLE devices that don't have any way to form a connection, instead they just embed data in advertising packets.
One issue is that Rumble ignores duplicates when scanning. This could be made optional depending on the use case.
The other issue was handling events. I tried using Central::on_event
, which works, but I couldn't see a nice way to get at the central
data in the main thread from the event context.
I've ended up just polling central.peripherals()
from my main thread for now, but it's not a great solution: https://github.com/miek/ruuvi-collector-rs/blob/master/src/main.rs#L109
Right now, accessing any adapter requires elevated privileges (eg. root). Is it possible to use an adapter without requiring elevated privileges? if yes, how would I do that? Thank you.
I am working on a project which requires me to use the std::error::Error (trait) as an associated type. It would help if the rumble crate provided the Error implementation for the rumble::Error enum.
Hi,
I'm currently toying around with an Windows 10 implementation (using winrt-rust) of rumble.
If you are interested in it I could create a PR!
For now connecting, discovering characteristics, reading and getting notified about a value change are working.
The rest is still to do as I wasn't able to understand the correct working of these API parts..
Thanks!
After expanding beyond the basic example I wanted to pass the Peripheral to a function to act on it. Sadly whenever I put "rumble::bluez::adapter::peripheral::Peripheral" in the parameters I get the following error:
error[E0603]: module `peripheral` is private
I am attempting to return Peripheral from a generic setup function, so that I can use this as a generic framework for some hardware I am testing. The Send trait prevents peripheral from being made into a trait object, which stops me from being able to return the peripheral from the function. This may be down to my inexperience with rust, but it does appear to be a weakness of the library.
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.