dbus-send version in python
Question: I have a working dbus-send invocation:

    
    
    #                                   OBJECT          INTERFACE        .MEMBER  CONTENT
    dbus-send --system --dest=org.bluez /org/bluez/hci0 org.bluez.Adapter.SetMode string:discoverable
    

Now I am trying to do the same in python, but since pitful documentation and
despite me trying all thinkable permutations all I get are errors on the
**last** step.

    
    
    import dbus
    bus = dbus.SystemBus()
    hci0 = bus.get_object('org.bluez', '/org/bluez/hci0')
    # everything good so far
    
    # v1
    hci0_setmode = hci0.get_dbus_method('SetMode', 'org.bluez.Adapter')
    hci0_setmode('discoverable')
    
    # v2
    iface = dbus.Interface(hci0, 'org.bluez.Adapter')
    iface.SetMode('discoverable')
    
    # v3
    iface = dbus.Interface(hci0, 'org.bluez.Adapter')
    hci0_setmode =iface.get_dbus_method('SetMode', 'org.bluez.Adapter')
    hci0_setmode('discoverable')
    

Whatever I do, the error is:

    
    
    dbus.exceptions.DBusException: org.freedesktop.DBus.Error.UnknownMethod: Method "SetMode" with signature "s" on interface "org.bluez.Adapter" doesn't exist
    

I have not found a way to tell me what mathod with what signatures exist and
besides this error message seemingly contradict with the inital dbus-send
invocation, which proofs that "org.bluez.Adapter.SetMode(s)" exists.


Answer: I found the solution by looking at the api:

    
    
    dbus-send --system --dest=org.bluez --type=method_call --print-reply /org/bluez/hci0 org.freedesktop.DBus.Introspectable.Introspect
    

and here is the python code:

    
    
    import dbus
    bus = dbus.SystemBus()
    hci0 = bus.get_object('org.bluez', '/org/bluez/hci0')
    props = dbus.Interface(hci0, 'org.freedesktop.DBus.Properties')
    props.Set('org.bluez.Adapter1', 'Discoverable', True)
    

I am still not sure why the initial dbus-send command even works. The only
reference to SetMode I can find elsewhere is here:
<http://svn.openmoko.org/developers/erin_yueh/bt/bt_adapter.py>.

