Skip to content

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

@sascha1337

Description

@sascha1337

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions