Code Monkey home page Code Monkey logo

qtawsiot's Introduction

QtAwsIoT

Author: Kurt Pattyn.

QtAwsIoT is Qt library that implements a client for Amazon AWS IoT.

Features

  • MQTT over secure WebSockets support, including SigV4 token authentication support
  • Keep-alive (aka ping)
  • Subscribing to topics
  • Publishing and receiving messages

Missing features

  • Native MQTT connectivity
    Currently only supports MQTT over secure Websockets.
  • Thing Shadows
  • Reconnection and resubscription
  • Queuing of messages

Building and installing

Prerequisites

  1. Qt version 5
  2. CMake v3.5 or higher.
  3. QtMqtt.

Building

# Check out the sources.
git clone https://github.com/KurtPattyn/QtAwsIoT.git

# Go into the checked out directory
cd QtAwsIoT

# Create build directory  
mkdir build

# Go into the build directory  
cd build

# Create the build files  
cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_SHARED_LIBS=OFF ..

# To make a release build, change `-DCMAKE_BUILD_TYPE=debug` to `-DCMAKE_BUILD_TYPE=release`  
# To make a dynamic library, change `-DBUILD_SHARED_LIBS=OFF` to `-DBUILD_SHARED_LIBS=ON`

# Build the library  
make

Run unit tests

make test

To enable testing of internal code, add -DPRIVATE_TESTS_ENABLED (default: OFF) to the cmake command line.

Installing

make install

This will install the library and the headers to CMAKE_INSTALL_PREFIX.
CMAKE_INSTALL_PREFIX defaults to /usr/local on UNIX/macOS and c:/Program Files on Windows.
To install in another location, add -DCMAKE_INSTALL_PREFIX="<custom location>" to the cmake command line.

Usage

Include the following in your CMakeLists.txt file

find_package(Qt5Core)	
find_package(Qt5NetWork)	
find_package(Qt5WebSockets)
find_package(Qt5Mqtt)
find_package(Qt5AwsIoT)

target_link_libraries(<target> Qt5::AwsIoT)

In your C++ source file include the QtAwsIoT module

#include <QtAwsIoT>

Examples

See the examples directory for examples how to use this library.

Enabling debug output

To enable debugging information of QtAwsIoT, the following environment variable can be defined.
QT_LOGGING_RULES="QtAwsIoT.*.debug=true"

qtawsiot's People

Contributors

frederikvannoote avatar kurtpattyn avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar

qtawsiot's Issues

cmake config failed on windows, cannot found FindQt5Mqtt.cmake file.

D:\GitHub\QtAwsIoT\build>cmake -DCMAKE_BUILD_TYPE=debug -DBUILD_SHARED_LIBS=OFF ..
CMake Error at CMakeLists.txt:73 (find_package):
By not providing "FindQt5Mqtt.cmake" in CMAKE_MODULE_PATH this project has
asked CMake to find a package configuration file provided by "Qt5Mqtt", but
CMake did not find one.

Could not find a package configuration file provided by "Qt5Mqtt" with any
of the following names:

Qt5MqttConfig.cmake
qt5mqtt-config.cmake

Add the installation prefix of "Qt5Mqtt" to CMAKE_PREFIX_PATH or set
"Qt5Mqtt_DIR" to a directory containing one of the above files. If
"Qt5Mqtt" provides a separate development package or SDK, be sure it has
been installed.

-- Configuring incomplete, errors occurred!
See also "D:/GitHub/QtAwsIoT/build/CMakeFiles/CMakeOutput.log".

Usage with QtCreator

Hello,

Firstly thanks for that perfect library.

I have made a clean install QtMqtt library and QtAwsIoT library. But after I am trying to run the pubsub.cpp on QtCreator I got many error about undefined references. So at the below my really basic begining. Could you pls show a guide that can basically publish a message in any qt projects.

Here is my .pro file

QT += core
QT -= gui

CONFIG += c++11

TARGET = aws_qt
CONFIG += console
CONFIG -= app_bundle

INCLUDEPATH += "/usr/local/include/QtMqtt/Qt5/"
"/usr/local/include/"
"/usr/local/include/QtAwsIoT/Qt5/"

TEMPLATE = app

SOURCES += main.cpp

LIBS += -L"/usr/local/lib/QtAwsIoT/Qt5/" -lAwsIoT

LIBS += -L"/usr/local/lib/QtMqtt/Qt5/" -lMqtt

And my source:

#include
#include
#include
#include
#include
#include
#include

int main(int argc, char *argv[])
{
QCoreApplication a(argc, argv);

qRegisterMetaType<QMqttProtocol::State>("QMqttProtocol::State");

return a.exec();

}

Errors:
/usr/local/lib/QtMqtt/Qt5/libMqtt.a(qmqttclient.cpp.o):-1: In function `QMqttClientPrivate::QMqttClientPrivate(QString const&, QMqttClient*)':

/home/nurhak/Desktop/qt_aws/QtMqtt-1.0.0/src/qmqttclient.cpp:134: error: undefined reference to `QWebSocket::QWebSocket(QString const&, QWebSocketProtocol::Version, QObject*)'

/usr/local/lib/QtMqtt/Qt5/libMqtt.a(qmqttclient.cpp.o):-1: In function `QMqttClientPrivate::connect(QMqttNetworkRequest const&, QMqttWill const&)':

/home/nurhak/Desktop/qt_aws/QtMqtt-1.0.0/src/qmqttclient.cpp:163: error: undefined reference to `QNetworkRequest::url() const'

.. etc

Test failing on macOS (10.13): The root CA certificate is not trusted for this purpose

Hello!

When trying to use this library on macOS 10.13, I get the following errors on running the test:

Error QMqttProtocol::Error::CONNECTION_FAILED "SSL errors encountered: The root CA certificate is not trusted for this purpose (17)\n."
Error QMqttProtocol::Error::CONNECTION_FAILED "Error connecting to MQTT server: 13 (The root CA certificate is not trusted for this purpose)."
Disconnected from AWS IoT

The library works perfectly on Linux and Windows.
I have verified that the Amazon Root CAs are available on the system.

Screen Shot 2019-08-21 at 15 11 02

The tests for QtMqtt do succeed, so the issue seems to be AWS-specific.

Any ideas?

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.