Skip to contentSkip to conversation

bluez and dbus - how to turn on discovery?

Bluez-users Andrew Kohlsmith 4 participants 8 messages Jan 15, 2007 – Jan 16, 2007 Bluetooth drivers

lore
Share & tools
lore
#0 lore raw

I've seen it in this list, but I can't find it now.

dbus is such a hairy pain in the ass, I hope that my opinion of it changes once I understand it more.

I would have thought that using a dbus "browser" such as kdbus I would have found a method to turn discovery on and off, as well as a bunch of other things. However, browsing the system bus it I see

:1.0/org/bluez as an object (with nothing else) org.bluez/org/bluez as an object (again with nothing else)

There isn't anything interesting in the session bus (at least not relating to Bluez, although I wasn't expecting to find anything.)

There is also an org.freedesktop.DBus interface in both the system and session busses with a ton of crap under it, but nothing bluez-related.

I haven't found much in the way of documentation on how to use this, yet we're all expected to use it. Can someone assist in giving perhaps a crash course in controlling bluez through dbus?

-A.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#1 lore raw

Hi Andrew,

Quoted 13 lines

dbus is such a hairy pain in the ass, I hope that my opinion of it changes once I understand it more.

I would have thought that using a dbus "browser" such as kdbus I would have found a method to turn discovery on and off, as well as a bunch of other things. However, browsing the system bus it I see

:1.0/org/bluez as an object (with nothing else) org.bluez/org/bluez as an object (again with nothing else)

There isn't anything interesting in the session bus (at least not relating to Bluez, although I wasn't expecting to find anything.)

Quoted 6 lines

There is also an org.freedesktop.DBus interface in both the system and session busses with a ton of crap under it, but nothing bluez-related.

I haven't found much in the way of documentation on how to use this, yet we're all expected to use it. Can someone assist in giving perhaps a crash course in controlling bluez through dbus?

the session bus is not used by BlueZ at all. We only use the system bus.

I never used kdbus and so I can't tell you if that would work or not. I always use the native interface from C or from Python. Some people use dbus-send, but I can't remember the syntax.

So in general if your adapter has been found you should see org org.bluez/org/bluez/hci0 object with the org.bluez.Adapter interface. This interface on this path provides a SetMode method that can be used to change the mode from "connectable" to "discoverable".

Since you speak about kdbus, I assume you don't use GNOME, but in that case you could install bluez-gnome and use the bluetooth-properties program to change the setting.

Regards

Marcel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#2 lore raw
Quoted 1 line · Marcel Holtmann

the session bus is not used by BlueZ at all. We only use the system bus.

Right, I figured that. :-)

Quoted 4 lines

So in general if your adapter has been found you should see org org.bluez/org/bluez/hci0 object with the org.bluez.Adapter interface. This interface on this path provides a SetMode method that can be used to change the mode from "connectable" to "discoverable".

dbus-send --system --dest=org.freedesktop.DBus --print-reply=1 /org/freedesktop/DBus org.freedesktop.DBus.ListNames
array [
org.freedesktop.DBus :1.4 org.bluez :1.9 :1.11 ]

I only have an org.bluez interface. No org.bluez.Adapter, even though hci0 is up and running great (hcid is running, and hidd is running, my BT mouse works great)

Quoted 3 lines

Since you speak about kdbus, I assume you don't use GNOME, but in that case you could install bluez-gnome and use the bluetooth-properties program to change the setting.

*nods* it looks like kdbus is working fine, as the dbus-send call itself is returning the exact same info... I just don't have a org.bluez.Adapter interface, nor do I have any hci0 object path.

Talking with the guys in FreeNode's #dbus channel too they say that this kind of return code is an error:

$ dbus-send --system --dest=org.bluez --print-reply=1 /org/bluez/hci0 
org.freedesktop.DBus.Introspectable.Introspect
   <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection 
1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
$

(/org/bluez also sends the exact same response) -- they claim that running that should give me some methods/interfaces, a child node or an error.

-A.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#7 lore raw
In reply to Marcel Holtmann
Quoted 3 lines · Marcel Holtmann

I never used kdbus and so I can't tell you if that would work or not. I always use the native interface from C or from Python. Some people use dbus-send, but I can't remember the syntax.

For the archives, this is how you do it with dbus-send:

$ dbus-send --system --dest=org.bluez --print-reply=1 /org/bluez/hci0 
org.bluez.Adapter.SetMode string:discoverable

Howver... I see no hci0, I see no methods (i.e. Adapter isn't there, SetMode isn't there)... it looks like the bluez 3.7 release does not have any kind of introspection or way of seeing what it provides programmatically. Is this true?

-A.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#3 lore raw
In reply to Andrew Kohlsmith
Quoted 6 lines · Andrew Kohlsmith

dbus-send --system --dest=org.freedesktop.DBus --print-reply=1 /org/freedesktop/DBus org.freedesktop.DBus.ListNames
array [
org.freedesktop.DBus :1.4 org.bluez :1.9 :1.11 ]

I only have an org.bluez interface.

Sorry, but this org.bluez is not an interface, but the bluez service.

Quoted 10 lines

Talking with the guys in FreeNode's #dbus channel too they say that this kind of return code is an error:

$ dbus-send --system --dest=org.bluez --print-reply=1 /org/bluez/hci0
org.freedesktop.DBus.Introspectable.Introspect
   <!DOCTYPE node PUBLIC "-//freedesktop//DTD D-BUS Object Introspection
1.0//EN"
"http://www.freedesktop.org/standards/dbus/1.0/introspect.dtd">
$
Quoted 2 lines

(/org/bluez also sends the exact same response) -- they claim that running that should give me some methods/interfaces, a child node or an error.

Yep, hcid is not answering the Introspect calls with the interface methods and their signatures.

-- Ulisses

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#4 lore raw
Quoted 1 line · Ulisses Furquim

Sorry, but this org.bluez is not an interface, but the bluez service.

I'm still trying to get my head around the dbus nomenclature. It's a work in progress (my understanding, that is). The various FAQs are helping, but it's taking some time yet.

Quoted 2 lines

Yep, hcid is not answering the Introspect calls with the interface methods and their signatures.

The latest bluez (3.8) does return a grammatically correct XML response now (empty node). I must ask again though -- how does one see which methods/properties bluez makes available through dbus? How does one find out which bluetooth interfaces (hci0, hci1, etc.) are available?

I mean ok I can see how dbus is taking a lot of programming load off of the bluez IPC requirements, but it seems that the soul of dbus was removed in the bluez implementation.

-A.

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

maintainer
#5 lore raw

Hi Andrew,

Quoted 5 lines
Quoted 1 line

Sorry, but this org.bluez is not an interface, but the bluez service.

I'm still trying to get my head around the dbus nomenclature. It's a work in progress (my understanding, that is). The various FAQs are helping, but it's taking some time yet.

we all had our problems. You actually need to use it to understand how it works.

Quoted 7 lines
Quoted 2 lines

Yep, hcid is not answering the Introspect calls with the interface methods and their signatures.

The latest bluez (3.8) does return a grammatically correct XML response now (empty node). I must ask again though -- how does one see which methods/properties bluez makes available through dbus? How does one find out which bluetooth interfaces (hci0, hci1, etc.) are available?

The introspection support is a problem and we know that. Mainly this is because the low-level D-Bus API (which we use) makes it kinda hard to easily support introspection. Especially if you have a lot of methods and signals it is kinda horrible. And right now we simply haven't added full introspection support. However we have a dbus-api.txt document in the the source code that describes all methods and signals.

And to answer your question. You connect to the org.bluez service and then you call org.bluez.Manager.ListAdapters() on the /org/bluez object path. The return will be a list of object paths that implement the org.bluez.Adapter interface. It sounds strange, but once you understood it, it makes perfect sense.

Quoted 3 lines

I mean ok I can see how dbus is taking a lot of programming load off of the bluez IPC requirements, but it seems that the soul of dbus was removed in the bluez implementation.

This has nothing to do with the soul of D-Bus. It is simply a big difference if you use a high-level language or C with no additional bindings.

Regards

Marcel

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users

#6 lore raw
In reply to Andrew Kohlsmith

Hello Andrew,

Quoted 4 lines

The latest bluez (3.8) does return a grammatically correct XML response now (empty node). I must ask again though -- how does one see which methods/properties bluez makes available through dbus? How does one find out which bluetooth interfaces (hci0, hci1, etc.) are available?

For now, have a look at

http://bluez.cvs.sourceforge.net/bluez/utils/hcid/dbus-api.txt?view=markup

You will find that there is a ListAdapters() method in the Manager hierarchy which will let you list current adapters, along the list of all other methods.

Regards,
Pierre-Yves

-------------------------------------------------------------------------
Take Surveys. Earn Cash. Influence the Future of IT
Join SourceForge.net's Techsay panel and you'll get the chance to share your opinions on IT & business topics through brief surveys - and earn cash
http://www.techsay.com/default.php?page=join.php&p=sourceforge&CID=DEVDEV
_______________________________________________
Bluez-users mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/bluez-users