MQTTSuite
Loading...
Searching...
No Matches
Mqtt.h
Go to the documentation of this file.
1/*
2 * MQTTSuite - A lightweight MQTT Integration System
3 * Copyright (C) Volker Christian <me@vchrist.at>
4 * 2022, 2023, 2024, 2025, 2026
5 *
6 * This program is free software: you can redistribute it and/or modify it
7 * under the terms of the GNU General Public License as published by the Free
8 * Software Foundation, either version 3 of the License, or (at your option)
9 * any later version.
10 */
11
12#ifndef MQTTSTORE_LIB_MQTT_H
13#define MQTTSTORE_LIB_MQTT_H
14
15#include "MariaDbStorage.h"
16
17namespace mqtt::mqttstore::lib {
18 class StoragePlan;
19}
20
21#include <iot/mqtt/client/Mqtt.h>
22
23#ifndef DOXYGEN_SHOULD_SKIP_THIS
24
25#include <cstdint>
26#include <list>
27#include <string>
28
29#endif
30
31namespace mqtt::mqttstore::lib {
32
33 class Mqtt : public iot::mqtt::client::Mqtt {
34 public:
35 explicit Mqtt(const std::string& connectionName,
36 const std::string& clientId,
37 std::uint8_t qoSDefault,
38 std::uint16_t keepAlive,
39 bool cleanSession,
40 const std::string& willTopic,
41 const std::string& willMessage,
42 std::uint8_t willQoS,
43 bool willRetain,
44 const std::string& username,
45 const std::string& password,
46 const std::list<std::string>& subTopics,
47 MariaDbStorage::ConnectionConfig connectionConfig,
48 const std::string& rawTable,
49 bool autoCreateRawTable,
50 StoragePlan storagePlan,
51 const std::string& sessionStoreFileName = "");
52
53 private:
54 using Super = iot::mqtt::client::Mqtt;
55
56 void onConnected() final;
57 [[nodiscard]] bool onSignal(int signum) final;
58
59 void onConnack(const iot::mqtt::packets::Connack& connack) final;
60 void onPublish(const iot::mqtt::packets::Publish& publish) final;
61 void onSuback(const iot::mqtt::packets::Suback& suback) final;
62
63 [[nodiscard]] static std::uint8_t getQos(const std::string& qoSString);
64
66 const std::uint8_t qoSDefault;
67 const bool cleanSession;
68 const std::string willTopic;
69 const std::string willMessage;
70 const std::uint8_t willQoS;
71 const bool willRetain;
72 const std::string username;
73 const std::string password;
75 };
76
77} // namespace mqtt::mqttstore::lib
78
79#endif // MQTTSTORE_LIB_MQTT_H
void onConnected() final
Definition Mqtt.cpp:74
const std::string willTopic
Definition Mqtt.h:68
Mqtt(const std::string &connectionName, const std::string &clientId, std::uint8_t qoSDefault, std::uint16_t keepAlive, bool cleanSession, const std::string &willTopic, const std::string &willMessage, std::uint8_t willQoS, bool willRetain, const std::string &username, const std::string &password, const std::list< std::string > &subTopics, MariaDbStorage::ConnectionConfig connectionConfig, const std::string &rawTable, bool autoCreateRawTable, StoragePlan storagePlan, const std::string &sessionStoreFileName="")
Definition Mqtt.cpp:37
const std::uint8_t qoSDefault
Definition Mqtt.h:66
MariaDbStorage storage
Definition Mqtt.h:65
void onConnack(const iot::mqtt::packets::Connack &connack) final
Definition Mqtt.cpp:97
const bool cleanSession
Definition Mqtt.h:67
const bool willRetain
Definition Mqtt.h:71
const std::string willMessage
Definition Mqtt.h:69
iot::mqtt::client::Mqtt Super
Definition Mqtt.h:54
const std::uint8_t willQoS
Definition Mqtt.h:70
bool onSignal(int signum) final
Definition Mqtt.cpp:79
const std::list< std::string > subTopics
Definition Mqtt.h:74
void onPublish(const iot::mqtt::packets::Publish &publish) final
Definition Mqtt.cpp:136
const std::string username
Definition Mqtt.h:72
const std::string password
Definition Mqtt.h:73
static std::uint8_t getQos(const std::string &qoSString)
Definition Mqtt.cpp:87
void onSuback(const iot::mqtt::packets::Suback &suback) final
Definition Mqtt.cpp:150