Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Bluez and dbus dependency on Mac OS / Crossplatform Ideas #1

Open
sascha1337 opened this issue Feb 17, 2021 · 1 comment
Open

Bluez and dbus dependency on Mac OS / Crossplatform Ideas #1

sascha1337 opened this issue Feb 17, 2021 · 1 comment

Comments

@sascha1337
Copy link

sascha1337 commented Feb 17, 2021

Here you are using blurz, inside dependencies, which has the dependency of dbus-1, not being included in Mac OS ( 10.14.6 )

....., output: Output { status: ExitStatus(ExitStatus(256)), stdout: "", stderr: "Package dbus-1 was not found in the pkg-config search path.\nPerhaps you should add the directory containing `dbus-1.pc\'\nto the PKG_CONFIG_PATH environment variable\nNo package \'dbus-1\' found\nPackage dbus-1 was not found in the pkg-config search path.\n.......

warning: build failed, waiting for other jobs to finish...
error: build failed


blurz = "0.4.0"

"Fix" of that issue was just running brew install dbus
followed by brew services start dbus to avoid following error:

dbus[11416]: Dynamic session lookup supported but failed: launchd did not provide a socket path, verify that org.freedesktop.dbus-session.plist is loaded!
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: D-Bus error

And even after that, there were further errors running the GW on mac - as i had predicted.
Makes sense, because dbus and especially bluez for bluetooth connections is for Linux kernel BLE communication only.
See here:

https://stackoverflow.com/a/63136987

❯ brew services start dbus
==> Successfully started `dbus` (label: org.freedesktop.dbus-session)
❯ cargo run --release --bin scan
    Finished release [optimized] target(s) in 0.47s
     Running `target/release/scan`
thread 'main' panicked at 'called `Result::unwrap()` on an `Err` value: D-Bus error: Failed to connect to socket /usr/local/var/run/dbus/system_bus_socket: No such file or directory (org.freedesktop.DBus.Error.FileNotFound)', bin/scan.rs:10:59

To scale and being able to run the Gateway crossplatform, we have multiple options.

  • Detect running OS at runtime, switching the library to be used ( will fail, as compilation will fail as described above )
  • Remove the dependency of blurz completely, and using another RUST BLE implementation, that coveres those cases
    ( On OSX, you have to use the native interface CoreBluetooth | IOBluetooth | bluetoothd )

Checking the crates for CoreBluetooth https://crates.io/keywords/CoreBluetooth gives us 3 options, with one being very active in development, worth a look at: https://crates.io/crates/btleplug

Quote:

btleplug is a Rust BLE library, support Windows 10, macOS, Linux, and possibly iOS. It is currently made up of parts of other abandoned projects with a goal of building a fully cross platform proof of concept.

Our goal is the bring in some of the outstanding PRs from other projects, expand the platform support, and possibly make the API surface more ergonomic for being a truly cross-platform library.

That btleplug library seems promising, having support for windows, android, mac os, linux, even iOS but has some limitations for each platforms especially async:
image

Another options would by some python wrapper accessiong Mac OS BLE, parsing output of blueutil for mac os (https://github.com/toy/blueutil) or like noble library for node.js solved, connecting via XpcConnection to the native Mac OS bluetoothd daemon service.

https://github.com/noble/noble/blob/master/lib/mac/highsierra.js#L18

--- or creating platform specific repos / build configs ála make and ./configure.

Just giving some feedback and ideas to solve those issues, to be more flexible to more endusers.
Maybe someone knows right away, which BLE functions are essential, and check that embedded image, if it would be an option trying to replace blurz with btleplug in some development branch.

@sascha1337
Copy link
Author

Looking at this repo, it is not usable as is, but i like the abstraction of a generic interface, so the high-level code does not need to care about the underlaying implementation. Thinking further, looking at the core lib for streams, we could also create some core library abstracted, to have one unified BLE lib working crossplatform.

gateway_core = { git = "https://github.com/iot2tangle/streams-gateway-core", branch="master"}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant