forked from collin80/SavvyCAN
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Add two new external libraries. SimpleCrypt is used to encrypt passwo…
…rds, QMQTT is an MQTT library that I was able to integrate into the codebase so there aren't any external dependencies. Both external projects have their own open source licenses. Those licenses are included. Also in this commit is some preliminary work to start adding MQTT support to SavvyCAN.
- Loading branch information
Showing
47 changed files
with
5,481 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -18,6 +18,7 @@ namespace CANCon { | |
KVASER, | ||
SERIALBUS, | ||
REMOTE, | ||
MQTT, | ||
NONE | ||
}; | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
This project is dual licensed under the Eclipse Public License 1.0 and the | ||
Eclipse Distribution License 1.0 as described in the epl-v10 and edl-v10 files. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,139 @@ | ||
QMQTT | ||
===== | ||
|
||
mqtt client for Qt | ||
|
||
**Please compile the library with Qt >= 5.3 version. On Windows you need to specify `CONFIG += NO_UNIT_TESTS`, since gtest is not supported.** | ||
|
||
SSL is enabled by default, if the version of OpenSSL < 1.0.2, SSL may not be supported. | ||
|
||
Disable the SSL in CMakeLists.txt (cmake): | ||
|
||
option( ${PROJECT_NAME}_SSL "Enable SSL support for MQTT" OFF ) | ||
|
||
Disable the SSL with src/mqtt/qmqtt.pro (qmake): | ||
|
||
CONFIG+=QMQTT_NO_SSL | ||
|
||
To add websocket support, compile the library with Qt >= 5.7, and specify 'CONFIG += QMQTT_WEBSOCKETS'. | ||
This also works when compiling qmqtt for WebAssembly. | ||
|
||
Usage | ||
===== | ||
|
||
In your QMake project, add: | ||
|
||
QT += qmqtt | ||
|
||
Connect using TCP: | ||
|
||
#include "qmqtt.h" | ||
|
||
QMQTT::Client *client = new QMQTT::Client(QHostAddress::LocalHost, 1883); | ||
client->setClientId("clientId"); | ||
client->setUsername("user"); | ||
client->setPassword("password"); | ||
client->connectToHost(); | ||
|
||
Connect using SSL: | ||
|
||
QSslConfiguration sslConfig = QSslConfiguration::defaultConfiguration(); | ||
// Add custom SSL options here (for example extra certificates) | ||
QMQTT::Client *client = new QMQTT::Client("example.com", 8883, sslConfig); | ||
client->setClientId("clientId"); | ||
client->setUsername("user"); | ||
client->setPassword("password"); | ||
// Optionally, set ssl errors you want to ignore. Be careful, because this may weaken security. | ||
// See QSslSocket::ignoreSslErrors(const QList<QSslError> &) for more information. | ||
client->ignoreSslErrors(<list of expected ssl errors>) | ||
client->connectToHost(); | ||
// Here's another option to suppress SSL errors (again, be careful) | ||
QObject::connect(client, &QMQTT::Client::sslErrors, [&](const QList<QSslError> &errors) { | ||
// Investigate the errors here, if you find no serious problems, call ignoreSslErrors() | ||
// to continue connecting. | ||
client->ignoreSslErrors(); | ||
}); | ||
|
||
Connect using WebSockets: | ||
|
||
QMQTT::Client *client = new QMQTT::Client("ws://www.example.com/mqtt", "<origin>", QWebSocketProtocol::VersionLatest); | ||
client->setClientId("clientId"); | ||
client->setUsername("user"); | ||
client->setPassword("password"); | ||
client->connectToHost(); | ||
|
||
Slots | ||
===== | ||
|
||
void setHost(const QHostAddress& host); | ||
void setPort(const quint16 port); | ||
void setClientId(const QString& clientId); | ||
void setUsername(const QString& username); | ||
void setPassword(const QString& password); | ||
void setKeepAlive(const int keepAlive); | ||
void setCleanSession(const bool cleansess); | ||
void setAutoReconnect(const bool value); | ||
void setAutoReconnectInterval(const int autoReconnectInterval); | ||
void setWillTopic(const QString& willTopic); | ||
void setWillQos(const quint8 willQos); | ||
void setWillRetain(const bool willRetain); | ||
void setWillMessage(const QString& willMessage); | ||
|
||
void connectToHost(); | ||
void disconnectFromHost(); | ||
|
||
quint16 subscribe(const QString& topic, const quint8 qos); | ||
void unsubscribe(const QString& topic); | ||
|
||
quint16 publish(const Message& message); | ||
|
||
Signals | ||
======= | ||
|
||
void connected(); | ||
void disconnected(); | ||
void error(const QMQTT::ClientError error); | ||
|
||
void subscribed(const QString& topic, const quint8 qos); | ||
void unsubscribed(const QString& topic); | ||
void published(const quint16 msgid, const quint8 qos); | ||
void pingresp(); | ||
void received(const QMQTT::Message& message); | ||
|
||
|
||
License | ||
======= | ||
|
||
New BSD License | ||
|
||
|
||
Contributors | ||
============= | ||
|
||
[@Kampfgnom](https://github.com/Kampfgnom) | ||
|
||
[@rafaeldelucena](https://github.com/rafaeldelucena) | ||
|
||
[@Vortex375](https://github.com/Vortex375) | ||
|
||
[@mwallnoefer](https://github.com/mwallnoefer) | ||
|
||
[@KonstantinRitt](https://github.com/KonstantinRitt) | ||
|
||
[@cncap](https://github.com/cncap) | ||
|
||
[@Psy-Kai](https://github.com/Psy-Kai) | ||
|
||
[@ejvr](https://github.com/ejvr) | ||
|
||
[@keytee](https://github.com/keytee) | ||
|
||
|
||
Authors | ||
======= | ||
|
||
[@emqplus](https://github.com/emqplus) Feng Lee <[email protected]> | ||
|
||
[@wguynes](https://github.com/wguynes) William Guynes <[email protected]> | ||
|
||
[@wuming123057](https://github.com/wuming123057) Xuan <[email protected]> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,30 @@ | ||
Eclipse Distribution License - v 1.0 | ||
|
||
Copyright (c) 2007, Eclipse Foundation, Inc. and its licensors. | ||
|
||
All rights reserved. | ||
|
||
Redistribution and use in source and binary forms, with or without | ||
modification, are permitted provided that the following conditions are met: | ||
|
||
Redistributions of source code must retain the above copyright notice, this | ||
list of conditions and the following disclaimer. | ||
|
||
Redistributions in binary form must reproduce the above copyright notice, | ||
this list of conditions and the following disclaimer in the documentation | ||
and/or other materials provided with the distribution. | ||
|
||
Neither the name of the Eclipse Foundation, Inc. nor the names of its | ||
contributors may be used to endorse or promote products derived from this | ||
software without specific prior written permission. | ||
|
||
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND | ||
ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED | ||
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE | ||
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR | ||
ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES | ||
(INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; | ||
LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON | ||
ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
(INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS | ||
SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
Oops, something went wrong.