Search code examples
rustbluetoothdbusbluez

Correct way to determine dbus destination for a proxy


I'm trying to figure out, what should be the correct way to determine what destination should be used with proxy when it's value is set to (null destination)?

I'm currently trying to receive Bluetooth signals of device data using rust's DBus impelementation.

Signals I'm getting:

signal time=1641856074.929459 sender=:1.2 -> destination=(null destination) serial=152 path=/org/bluez/hci0/dev_<mac>; interface=org.freedesktop.DBus.Properties; member=PropertiesChanged
   string "org.bluez.Device1"
   array [
      dict entry(
         string "ManufacturerData"
         variant             array [
               dict entry(
                  uint16 1177
                  variant                      array of bytes [
                        05 0f c0 1e ff cd 59 ff e4 ff e0 03 e4 4c 36 b0 31 46
                        c0 cb 4e 3d 3e 12
                     ]
               )
            ]
      )
   ]
   array [
   ]

I happened to figure out by just testing out different things that the destination for the proxy is org.bluez.

Code I ended up using

    let conn = Connection::new_system()?;
    {
        let proxy = conn.with_proxy(
            "org.bluez",
            "/org/bluez/hci0/dev_C0_CB_4E_3D_3E_12",
            Duration::from_millis(5000),
        );
    // --snip--

This works, but I'm not sure how I should've properly find this out or whether this is even the right approach.


Solution

  • Looking at the documentation for Proxy it says the first field is the BusName:

        pub struct Proxy<'a, C> {
            pub destination: BusName<'a>,
            pub path: Path<'a>,
            pub timeout: Duration,
            pub connection: C,
        }
    

    Looking at the details for that field is says that it is the D-Bus Service.

    destination: BusName<'a> 
        Destination, i e what D-Bus service you’re communicating with
    

    Looking at the BlueZ documentation for the org.bluez.Device1 interface it says the service is org.bluez

    > Service       org.bluez
    > Interface     org.bluez.Device1 
    > Object path   [variable prefix]/{hci0,hci1,...}/dev_XX_XX_XX_XX_XX_XX
    

    So you are right and the links to the above documentation is how you would work it out.