While helping one of my customers, I asked Ian Craggs @icraggs to prototype an MQTT+D-Bus bridge to cloud enable GENIVI, Tizen and Automotive Grade Linux. Ian surprised me with a command line solution that MQTT enables them in 5 minutes. I expect we’ll still develop a bridge component for GENIVI but this is a trivially easy solution folks can do now.
You can test it against this MQTT MessageSight instance ip=184.108.40.206 port=1883 in the cloud and use the MQTT Client web app on http://m2m.demos.ibm.com to test your GENIVI/Tizen/AGL publishing and subscribing.
Ian’s quick and easy solution as follows:
I have been experimenting with getting information from D-Bus to MQTT and back, and have come up with the following simple methods, using the Paho C MQTT client, available from http://www.eclipse.org/paho/ source repository http://git.eclipse.org/c/paho/org.eclipse.paho.mqtt.c.git/
These methods do no transformation or extraction of information at the moment, but it is easy to change them to get the exact information we need. Any questions, please ask.
D-Bus to MQTT
There is a Linux program called dbus-monitor which will listen for events and print them to stdout. Using the stdinpub sample of the Paho C client (src/samples directory), raw Linux desktop notification messages can be published to an MQTT server by using a command like this:
dbus-monitor –session interface=org.freedesktop.Notifications | stdinpub Notifications –delimiter -1 –verbose –maxdatalen 1000
You can test this using the command:
notify-send summary body
The raw output looks like this (you can see where the “summary” and “body” fields end up) :
signal sender=:1.78232 -> dest=:1.273 serial=122 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=NotificationClosed
method call sender=:1.81115 -> dest=org.freedesktop.Notifications serial=5 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=GetServerInformation
method call sender=:1.81115 -> dest=org.freedesktop.Notifications serial=6 path=/org/freedesktop/Notifications; interface=org.freedesktop.Notifications; member=Notify
variant byte 1
variant string “”
We can easily extract just the relevant data from the events we are interested in.
MQTT to D-Bus
Using another program called notify-send and another sample stdoutsub (available from Paho again), we can use MQTT to create desktop events via D-Bus:
stdoutsub notify –delimiter newline | xargs -I %body –delimiter \\n notify-send summary %body
We can use dbus-send instead of notify-send to create events on any D-Bus interface.