Published:

Jarle Aase

Monthly update, December 2023

bookmark 1 min read

Projects

I spent quite some time in December planning what to do in 2024, and how.

There were many power outages in my village in December, so I set aside software and spent two days replacing the old fuze box with a new one. The new one allows me to switch the power to the house from the not so reliable electricity company (one phase) to a 3 phase power generator (6 Kw). I also added some meters to see how much power I consume for various things, and a timer that turns on my water boiler for only one hour each night when the electricity is cheaper.

New Power Distribution

I also took some days off to spend more time with my 9 dogs for christmas, and to put a panel outside my office. The building is very old, so upgrades makes a big difference.

Refactoring the wall

nsblast

I added the new UI to the embedded web server and added bulding of the react UI files to CMake. I also added a new target for the REST api to facilitate permission settings from the UI.

Next-app

From mid December, I worked exclusively on next-app. The target is to have a Proof of Concept (POC) ready by the end of January. That is an ambitious goal! I have not worked with QML for years, never used QT6, and not used gRPC for anything complex. In the last 5 years, I have not used SQL - all the database work has been with mongodb, arangodb and similar "noqsl" databases. With nextapp, the initial implementation use MariaDB with a "classic" SQL database architecture. However, the database is an implementation detail in the back-end server, so I can change that at any time. All the communication between the back-end server and the users applications use gRPC and Protobuf messages.

QT gRPC support

One nice surprise for me was that QT6 has it's own gRPC support! It's much simpler to use than the standard C++ stuff generated by Googles toolkit.

This is all I needed to add in CMakeList.txt to add gRPC to the QT project:

set (protofile "${CMAKE_CURRENT_SOURCE_DIR}/../proto/nextapp.proto")

qt_add_protobuf(MyProtoMessageLib
    QML
    QML_URI nextapp.pb
    PROTO_FILES ${protofile}
)

qt_add_grpc(MyGrpcClient CLIENT
    PROTO_FILES ${protofile}
)

Then, in the code I can call into async gRPC methods from the main thread, in a very simple manner:

client_->attachChannel(std::make_shared<QGrpcHttp2Channel>(channelOptions));
auto info_call = client_->GetServerInfo({});
info_call->subscribe(this, [info_call, this]() {
        nextapp::pb::ServerInfo se = info_call->read<nextapp::pb::ServerInfo>();
        LOG_INFO << "Connected to server version " << server_version_;
    }, [this](QGrpcStatus status) {
        LOG_ERROR_N << "Comm error: " << status.message();
    });

The code for my QT gRPC stuff is here:

I'll add an article about QT gRPC to my gRPC blog series as soon as I find the time to write some demo code.

Well done QT!