Serial Studio 1.1.6
A dashboard software for your embedded projects
|
#include <Client.h>
Public Slots | |
void | loadCaFile () |
void | connectToHost () |
void | toggleConnection () |
void | disconnectFromHost () |
void | setQos (const quint8 qos) |
void | lookup (const QString &host) |
void | setPort (const quint16 port) |
void | setHost (const QString &host) |
void | setRetain (const bool retain) |
void | setClientMode (const int mode) |
void | setTopic (const QString &topic) |
void | loadCaFile (const QString &path) |
void | setSslProtocol (const int index) |
void | setSslEnabled (const bool enabled) |
void | setUsername (const QString &username) |
void | setPassword (const QString &password) |
void | setKeepAlive (const quint16 keepAlive) |
void | setMqttVersion (const int versionIndex) |
Signals | |
void | qosChanged () |
void | portChanged () |
void | hostChanged () |
void | topicChanged () |
void | retainChanged () |
void | usernameChanged () |
void | passwordChanged () |
void | keepAliveChanged () |
void | connectedChanged () |
void | caFilePathChanged () |
void | clientModeChanged () |
void | sslEnabledChanged () |
void | sslProtocolChanged () |
void | mqttVersionChanged () |
void | lookupActiveChanged () |
Public Member Functions | |
quint8 | qos () const |
bool | retain () const |
quint16 | port () const |
QString | host () const |
QString | topic () const |
int | clientMode () const |
int | sslProtocol () const |
int | mqttVersion () const |
bool | sslEnabled () const |
QString | username () const |
QString | password () const |
quint16 | keepAlive () const |
bool | lookupActive () const |
bool | isSubscribed () const |
bool | isConnectedToHost () const |
StringList | qosLevels () const |
StringList | clientModes () const |
StringList | mqttVersions () const |
StringList | sslProtocols () const |
QString | caFilePath () const |
quint16 | defaultPort () const |
QString | defaultHost () const |
Static Public Member Functions | |
static Client & | instance () |
Properties | |
quint16 | port |
quint8 | qos |
QString | host |
bool | retain |
quint16 | keepAlive |
QString | topic |
int | mqttVersion |
int | clientMode |
QString | username |
QString | password |
bool | sslEnabled |
int | sslProtocol |
bool | isConnectedToHost |
bool | lookupActive |
StringList | mqttVersions |
StringList | clientModes |
StringList | qosLevels |
StringList | sslProtocols |
quint16 | defaultPort |
QString | defaultHost |
QString | caFilePath |
Private Slots | |
void | sendData () |
void | resetStatistics () |
void | onConnectedChanged () |
void | lookupFinished (const QHostInfo &info) |
void | onError (const QMQTT::ClientError error) |
void | onFrameReceived (const QByteArray &frame) |
void | onSslErrors (const QList< QSslError > &errors) |
void | onMessageReceived (const QMQTT::Message &message) |
Private Member Functions | |
Client () | |
Client (Client &&)=delete | |
Client (const Client &)=delete | |
Client & | operator= (Client &&)=delete |
Client & | operator= (const Client &)=delete |
~Client () | |
void | regenerateClient () |
Private Attributes | |
QString | m_topic |
bool | m_sslEnabled |
int | m_sslProtocol |
bool | m_lookupActive |
QString | m_caFilePath |
quint16 | m_sentMessages |
MQTTClientMode | m_clientMode |
QVector< QByteArray > | m_frames |
QPointer< QMQTT::Client > | m_client |
QSslConfiguration | m_sslConfiguration |
The Client class.
Implements a simple MQTT client, which allows Serial Studio to upload received frames to a MQTT broker so that other devices and/or services can make use of that information. By acting as a MQTT subscriber, Serial Studio can display & process frames from a remote Serial Studio instance that is setup as a MQTT publisher. As you might notice, this has a lot of interesting applications.
For example, you can receive frames from a CanSat mission and display them almost in real-time in another location, such as the "ground control" centre or by the media team which streams the GCS display on the internet as the mission is developing.
|
explicitprivate |
Constructor function
|
privatedelete |
|
privatedelete |
|
private |
Destructor function
QString MQTT::Client::caFilePath | ( | ) | const |
Returns the path of the currently loaded *.ca file
|
signal |
int MQTT::Client::clientMode | ( | ) | const |
Returns the client mode, which can have the following values:
|
signal |
StringList MQTT::Client::clientModes | ( | ) | const |
Returns a list with the available client operation modes.
|
signal |
|
slot |
Tries to establish a TCP connection with the MQTT broker/server.
|
inline |
|
inline |
|
slot |
Disconnects from the MQTT broker/server
QString MQTT::Client::host | ( | ) | const |
Returns the IP address of the MQTT broker/server
|
signal |
|
static |
Returns a pointer to the only instance of this class
bool MQTT::Client::isConnectedToHost | ( | ) | const |
bool MQTT::Client::isSubscribed | ( | ) | const |
quint16 MQTT::Client::keepAlive | ( | ) | const |
Returns the keep-alive timeout interval used by the MQTT client.
|
signal |
|
slot |
Prompts the user to select a *.ca file and loads the certificate into the SSL configuration.
|
slot |
Reads the CA file in the given path and loads it into the SSL configuration handler for the MQTT connection.
|
slot |
Performs a DNS lookup for the given host name
bool MQTT::Client::lookupActive | ( | ) | const |
|
signal |
|
privateslot |
Sets the host IP address when the lookup finishes. If the lookup fails, the error code/string shall be shown to the user in a messagebox.
int MQTT::Client::mqttVersion | ( | ) | const |
Returns the index of the MQTT version, corresponding to the list returned by the mqttVersions()
function.
|
signal |
StringList MQTT::Client::mqttVersions | ( | ) | const |
Returns a list with the supported MQTT versions
|
privateslot |
Subscribe/unsubscripe to the set MQTT topic when the connection state is changed.
|
privateslot |
Displays any MQTT-related error with a GUI message-box
|
privateslot |
Registers the given frame data to the list of frames that shall be published to the MQTT broker/server
|
privateslot |
Reads the given MQTT message and instructs the IO::Manager
module to process received data directly.
|
privateslot |
Displays the SSL errors that occur and allows the user to decide if he/she wants to ignore those errors.
QString MQTT::Client::password | ( | ) | const |
Returns the MQTT password
|
signal |
quint16 MQTT::Client::port | ( | ) | const |
Returns the TCP port number used for the MQTT connection
|
signal |
quint8 MQTT::Client::qos | ( | ) | const |
Returns the quality-of-service option, available values:
|
signal |
StringList MQTT::Client::qosLevels | ( | ) | const |
Returns a list with the available quality-of-service modes.
|
private |
|
privateslot |
Clears the JSON frames & sets the sent messages to 0
bool MQTT::Client::retain | ( | ) | const |
Returns true
if the retain flag is enabled
|
signal |
|
privateslot |
Publishes all the received data to the MQTT broker
|
slot |
Changes the operation mode of the MQTT client. Possible values are:
|
slot |
Changes the IP address of the MQTT broker/host
|
slot |
Sets the maximum time interval that is permitted to elapse between the point at which the Client finishes transmitting one Control Packet and the point it starts sending the next packet.
|
slot |
|
slot |
Changes the password used to connect to the MQTT broker/server
|
slot |
Changes the TCP port number used for the MQTT communications.
|
slot |
Changes the quality of service level of the MQTT client.
|
slot |
If set to true
, the retain
flag shall be appended to the MQTT message so that new clients connecting to the broker will immediately receive the last "good" message.
|
slot |
Enables/disables SSL/TLS communications with the MQTT broker
|
slot |
Changes the SSL protocol version to use for the MQTT connection.
|
slot |
Changes the MQTT topic used by the client.
|
slot |
Changes the username used to connect to the MQTT broker/server
bool MQTT::Client::sslEnabled | ( | ) | const |
Returns true
if SSL/TLS is enabled
|
signal |
int MQTT::Client::sslProtocol | ( | ) | const |
Returns the selected SSL/TLS protocol index
|
signal |
StringList MQTT::Client::sslProtocols | ( | ) | const |
Returns a list with the supported SSL/TLS protocols
|
slot |
Connects/disconnects the application from the current MQTT broker. This function is used as a convenience for the connect/disconnect button.
QString MQTT::Client::topic | ( | ) | const |
Returns the MQTT topic used
|
signal |
QString MQTT::Client::username | ( | ) | const |
Returns the MQTT username
|
signal |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
private |
|
read |
|
readwrite |
|
read |
|
read |
|
read |
|
readwrite |
|
read |
|
readwrite |
|
read |
|
readwrite |
|
read |
|
readwrite |
|
readwrite |
|
readwrite |
|
read |
|
readwrite |
|
readwrite |
|
readwrite |
|
read |
|
readwrite |
|
readwrite |