Tuesday, June 12, 2018

Cross-compiling QtMqtt module for Raspberry Pi

A previous post of mine described the Qt module for MQTT protocol, and how to compile it for the Android platform. That seems a good fit to develop a client application for a dashboard for instance, where you can subscribe to different topics and monitor the evolution of such items.
Ok you'll say, but what about creating MQTT publishers, i.e. devices that may have sensors and will provide the readings with MQTT messages?

Saturday, June 9, 2018

Cross-compiling QtMqtt module for Android

As the MQTT potocol continues to get traction in the IoT world, more and more people seems to rely on Qt MQTT module to implement clients applications that can communicate over the MQ telemetry transport (MQTT) protocol. And given the device-based nature of such clients, it's very likely that you may need the module available for different platforms/architectures.

Thursday, June 7, 2018

QLocalSocket under *nix is SOCKET_STREAM only

While developing a library for Qt to interact with Sense HAT add-on board for Raspberry Pi, I started with the software side, the Sense Emulator. This application emulates the components of the board, and makes the data from emulated sensors, stick and LED matrix available through several files. Under *nix the stick events are provided via a Unix domain local socket as datagrams, constructed in Python like this:

(socket.AF_UNIX, socket.SOCK_DGRAM, '/dev/shm/rpi-sense-emu-stick')

So I thought QLocalSocket was the perfect fit for connecting the library to the Sense Emulator server socket, receive and decode the data and publish it as signals to Qt applications using the library.
But as I started making some tests, I was not able to receive any data. And although everything was in place, it was not working.

Sunday, June 3, 2018

Just one library with different immplementations? d-pointer desing pattern to the rescue

I'm developing a library based on Qt to access the Sense HAT add-on for Raspberry Pi. It's based on ideas and code from Qt's experimental module and from this other library. The ultimate goal is to provide a library that can be used with either the actual hardware or the Sense Emulator without any code changes to the program using it.

Qt default parameter value

What is the proper place for the default value of a parameter ? Just in function definition, or declaration, or both places? Qt code has plenty of methods using this approach i.e. QDialog::QDialog(QWidget * parent = 0, Qt::WindowFlags f = 0) so what if you're defining a new method and need a similar behavior?

QML signals to C++? No, the other way around please

While developing an application with QML and C++ please refrain to emit signals in QML that should be handled by C++ code. Just the opposite, keep QML as the UI layer and expose your C++ object to QML (as a context property or with qmlRegisterXXX) and then call a slot or a Q_INVOKABLE method of this object from QML.