Qt, Ofono, D-Bus and QML – Part 1

Today I want to describe how to use D-Bus in Qt and more in detail how to use the Ofono-D-Bus-API in a Qt-Application. The Qt-Application is separated in two parts, the C++ part and the QML part. I’m going to describe how you can get the Ofono-D-Bus-API into a Qt application and how you can connect your QML part to the methods ands signals.

For all who don’t know D-Bus, it’s a interprocess communication system which is the standard on linux desktop systems and used on embedded platforms as well. It has replaced Bonobo/Corba on GNOME and DCOP on KDE. D-Bus has language bindings to all the major programming languages. For Qt you don’t need any additional library.

Ofono is an abstraction layer for GSM-Modems. It’s mainly developed by Intel and Nokia to use it in the upcoming MeeGo-Distribution.

So how to use these components to create great new phone applications? Let’s describe that in a few steps.

Install Phonesim

First of all, I assume you don’t have a GSM-Modem connected to your development computer. Therefore we use a tool the simulate this part. Phonesim is a great tool for that and it’s fairly easy to install:

git clone git://git.freesmartphone.org/phonesim.git
cd phonesim
./phonesim -p 12345 -gui modems/generic.xml

After executing the last line, you won’t see anything. Phonesim will wait until it gets a connection through the given port (-p) and the right AT-Commands to activate the simulated GSM-Modem. But our intention is not to do this manually! We want Ofono to do this for us, so let’s install it.

Hint: There is also a Ofono-Branch of Phonesim. It’s located at: git://git.kernel.org/pub/scm/network/ofono/phonesim.git

Install Ofono

git clone git://git.kernel.org/pub/scm/network/ofono/ofono.git
cd ofono
make install

The bootstrap command creates the configure script with the autotools. Without any additional configure parameters, the installed configuration file will be located in /usr/local/etc/ofono/modem.conf. There we need to add our simulated GSM-Modem Phonesim.


Ok, now let’s run Ofono:

ofonod -nd '*'

The exported variable and the given arguments give you a reasonably output to detect errors. The command must be run as root because it creates a service on the D-Bus system bus. If you don’t want Ofono to run as root, change the policy in /etc/dbus-1/system.d/ofono.conf:

<policy user="devel">
 <allow own="org.ofono"/>
 <allow send_destination="org.ofono"/>

Change the user= entry accordingly.

Activate the modem
Now it’s time to activate the modem to see if everything is working well. Therefore we need dbus-send to send the suitable command to the Ofono-D-Bus-API:

dbus-send --print-reply --system --dest=org.ofono /phonesim org.ofono.Modem.SetProperty string:"Powered" variant:boolean:"true"

Now you should see the Phonesim application window popping up.

Phonesim application window

With dbus-send you can execute further methods on the Ofono-D-Bus-API. In part 2 I’ll describe how to connect to the API from within Qt.


– Necessary bootstrap command added to the ofono install listing.

– Hint to the Ofono-Branch of Phonesim added.


One Response to Qt, Ofono, D-Bus and QML – Part 1

  1. […] and QML – Part 2 Since we have already a running Ofono with an activated modem (see part 1), we can continue with creating Proxy-Classes for […]

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out /  Change )

Google+ photo

You are commenting using your Google+ account. Log Out /  Change )

Twitter picture

You are commenting using your Twitter account. Log Out /  Change )

Facebook photo

You are commenting using your Facebook account. Log Out /  Change )


Connecting to %s

%d bloggers like this: