Introduction
In this guide we are going to see how to use DaaS-IoT, a compact C/C++ for net auto-organized overlay-mesh, into a Qt6 application. Step after step, we will configure the project, link the library and show you a minimal example.
DaaS overview
DaaS, acronym of “Device as a Service”, is a net protocol thinked for create overlay-mesh auto-organized and data-oriented relying on existing infrastructures, managing with transparency transceiver, protocols and hardware platforms (CPU, MCU,SoC) heterogeneity. In the heart of DaaS innovation are four innovations – EPRN for resilient interoperability, PSRC for protocol dynamic change, ATFS for devices dynamic and precise synchronization and FRMD for distributed data fragmentation and recomposition – that permit for each nodes, real time valuation of channel metrics and to be able to select the most efficient and safe path to follow with the help of artificial intelligence logics. Regarding this method, DaaS makes the net itself an active part of information flow management, ensuring continuity of service and fast development of new solutions.
DaaS-IoT overview
DaaS-IoT SDK offer a new precompiled standard C/C++ library, technical documentation and usable desktop application (Windows,Linux, macOS), Node.js and Java environments, and microcontrollers such as ESP32 and dsPIC, ensuring that any developer can create application directly with DaaS protocol. Thanks to a driver based modular architecture, DaaS-IoT can support the standard communication protocol – from TCP/IP and UART to MQTT5.0, Bluetooth 5.2, LoRa and many other – furthermore make sure about temporal synchronization, data convergence and communication resilience even with Edge and Fog computing scenarios. Library itself simplifies the provisioning self‑organizing of nodes, “reciver” cloud configuration and hot re-routing of paths, making life simple to developers allowing them to focus on applicative logic maintaining performance, security and scalability.
DaaS-IoT & Qt
This interface integrates daas functionalities with Qt resources.
The DaaS-IoT SDK for QT includes a ready to use precompiled C++ wrapper (MinGW® on Windows and GCC su Linux/macOS). All you need is to add the
package to your Qt project and configure the path to the headers and
libraries.
Thanks to an unified API, developers can make customized DaaS-IoT nodes without struggling about net interfaces lower level details: : Wi‑Fi, Bluetooth 5.2, LoRa, UART or any other channel supported for included SDK drivers.
The driver-based architecture of DaaS-IoT ensures, when new technologies or protocols are available, the possibility to add or update his driver to automatically extend the communication capabilities of Qt node, always maintaining efficiency, resilience and temporal synchronization based on ATS (Adaptive Time Synchronization).
QDaaS developing in Qt
The QDaaS library extends the operation of the QObject classes, for
interfacing with the operation of the Qt graphics libraries, and IDaasApiEvent
which handles sending and receiving data via events
Available Methods:
The methods for using the library are listed below. All necessary calls are exposed as invocable QML methods. Here is a summary of the most common ones:
- doInit(QString sid, QString din)
- perform()
- map(QString remoteDIN, QString linkType, QString uri, QString skey)
- enableDriver(QString linkType, QString uri)
- locate(QString remoteDIN)
- push(QString remoteDIN, QString typeset, QString data
- pull(QString payload_size, QString remoteDIN)
- getWrapperInfo()
- getError(int eType) const
- getPayload() const
- configIni(int, int, int, QString, int)
Getter/Setter:
- getDIN()
- getSID()
- getLINK()
- getURI()
- getPORT
- setDIN(int DIN)
- setSID(int SID)
- setLINK(int LINK)
- setURI(QString URI)
- setPORT(int PORT)
Syntax:
QDaaS(QObject* parent = nullptr);
Method Type:
Wrapper class constructor and configuration interface.
Description:
The QDaaS constructor initialises the Qt wrapper object for the DaaS library by creating a DaaS-Qt node within it, preparing the path for the configuration file and loading (or creating) the INI file for the settings.
Notes:
If the Config directory does not exist, it is created automatically.
Opening the INI file in ReadWrite mode ensures that if the file was not present, an empty file is created ready for settings.
It is advisable to handle any errors when opening the file (in addition to the simple log) if additional robustness is required
Syntax:
QDaaS(QObject* parent = nullptr);
Method Type:
Wrapper class constructor and configuration interface.
Description:
The QDaaS constructor initialises the Qt wrapper object for the DaaS library by creating a DaaS-Qt node within it, preparing the path for the configuration file and loading (or creating) the INI file for the settings.
Notes:
If the Config directory does not exist, it is created automatically.
Opening the INI file in ReadWrite mode ensures that if the file was not present, an empty file is created ready for settings.
It is advisable to handle any errors when opening the file (in addition to the simple log) if additional robustness is required
Syntax:
QDaaS(QObject* parent = nullptr);
Method Type:
Wrapper class constructor and configuration interface.
Description:
The QDaaS constructor initialises the Qt wrapper object for the DaaS library by creating a DaaS-Qt node within it, preparing the path for the configuration file and loading (or creating) the INI file for the settings.
Notes:
If the Config directory does not exist, it is created automatically.
Opening the INI file in ReadWrite mode ensures that if the file was not present, an empty file is created ready for settings.
It is advisable to handle any errors when opening the file (in addition to the simple log) if additional robustness is required
Syntax:
QDaaS(QObject* parent = nullptr);
Method Type:
Wrapper class constructor and configuration interface.
Description:
The QDaaS constructor initialises the Qt wrapper object for the DaaS library by creating a DaaS-Qt node within it, preparing the path for the configuration file and loading (or creating) the INI file for the settings.
Notes:
If the Config directory does not exist, it is created automatically.
Opening the INI file in ReadWrite mode ensures that if the file was not present, an empty file is created ready for settings.
It is advisable to handle any errors when opening the file (in addition to the simple log) if additional robustness is required
Syntax:
doInit(QString sid, QString din);
Method Type:
Node initialization method.
Description:
Initializes the QDaaS node using the provided SID and device identifiers.
Prints debug output confirming the operation if successful.
Notes:
Return 0 on success ( ERROR_NONE ), -1 on failure.
Prints SID, DIN, and “Agent initialized” on success.
Syntax:
perform();
Method Type:
Execution method.
Description:
Starts the QDaaS node in multithreaded mode, activating configured drivers and core DaaS logic.
Notes:
Returns 0 on success ( ERROR_NONE ), -1 on failure.
Prints messages confirming successful startup.
Syntax:
map(QString remoteDIN, QString linkType, QString uri, QString skey);
Method Type:
Remote mapping method.
Description:
Associates a remote node (remoteDIN) with the local node,
optionally specifying the link type (linkType), the URI of the
channel and a security key (skey).
Notes:
Returns 0 on success ( ERROR_NONE ), -1 on failure.
Depending on the parameters passed, it handles three mapping cases:
If linkType and uri and skey are empty, it only maps remoteDIN.
If skey is empty, it maps remoteDIN with linkType and uri.
Otherwise it performs the complete mapping with all four parameters.
If successful, it prints to the console
Syntax:
enableDriver(QString linkType, QString uri);
Method Type:
Driver activation method.
Description:
Driver activation method.
Notes:
Converts linkType in link_t and uri in const char* parameters and enables the driver. Prints the enabled URI on success.
Returns 0 on success (DERROR_NONE), -1 on failure.
Syntax:
locate(QString remoteDIN);
Method Type:
Node discovery method.
Description:
The locate function searches for and locates a remote node identified by remoteDIN within the DaaS network.
Notes:
In case of success, it prints a confirmation message in the console.
return 0 if localisation was successful (DERROR_NONE), -1 in case of error
Syntax:
push(QString remoteDIN, QString typeset, QString data);
Method Type:
Data sending method.
Description:
The push method sends a data packet (data) to a remote node (remoteDIN) using the specified typeset.
Notes:
If successful, it prints a confirmation message in the console. Return 0 if sending was successful (DERROR_NONE) or -1 in case of error
Syntax:
pull(QString payload_size, QString remoteDIN);
Method Type:
Data receiving method.
Description:
The pull method receives a data packet (data) sent via the push method from a remote node (remoteDIN).
Notes:
If successful, it prints a confirmation message in the console. Returns 0 if reception was successful (DERROR_NONE), -1 in case of error.
Syntax:
getWrapperInfo();
Method Type:
Information method
Description:
Returns a QJsonObject with wrapper metadata
Notes:
Use to inspect wrapper state of version
Syntax:
getError(int eType) const;
Method Type:
Error interpretation method.
Description:
Returns a QString describing the error associated with the given code
Notes:
Input is the return value of a method
Syntax:
getPayload() const;
Method Type:
Payload access method.
Description:
Returns the last received payload.
Notes:
Output can be bound to UI components.
Syntax:
configini(int, int , int, QString, int);
Method Type:
INI configuration method.
Description:
Configures values inside the .ini file for the QDaaS node.
Notes:
Accepts multiple parameter types and updates config file
Example of use – creating a node
- Install Qt inside your computer (if you do not have a version of Qt inside your computer)
- Get the package daas-sdk-qt-xxx.tar
- Create a new project (FIle > New Project)
- Select the Compilation Kit (CMake).
- Copy the contents of the folder into the main project folder
- Once the folder has been created, a file with the name CMakeLists.txt will also be created.
Within this file, the following lines must be added:
- Add_compiler_definition (PROJECT_SOURCE_DIR = ‘CMAKE_SOURCE_DIR’) # Defines where the library is located (PROJECT_SOURCE_DIR is the directory of the project).
- add_subdirectory(QDaaS) # Adds the library to the project
- target_include_directories(appQDaaSNode PRIVATE
- ${CMAKE_SOURCE_DIR}/QDaaS
- ${CMAKE_SOURCE_DIR}/QDaaS/includes # If daas.hpp is in ‘includes’ )
# To add two folders to the list of paths where the compiler looks for header files (.h, .hpp) when compiling the target appQDaaSNode
- target_link_libraries(appQDaaSNode PRIVATE QDaaS)
# To build the appQDaaSNode target (typically an executable) and allow the linker to also link (link) the QDaaS library.
After these steps, the environment is ready to develop the custom node
also employ DaaS-IoT services in Qt.
Lascia un commento