NetBurner 3.5.6
PDF Version
config_mqtt_obj.h
1#ifndef __CONFIG_MQTT_OBJ_H
2#define __CONFIG_MQTT_OBJ_H
3
4#include <predef.h>
5#include <config_obj.h>
6#include <nbstring.h>
7
8class config_MqttLWT : public config_obj
9{
10 public:
11 config_string topic{"", "Topic", "Topic to publish Last Will & Testament message to"};
12 config_string message{"", "Message", "LWT Message to publish on non-normal disconnect"};
13 config_uint sessExpIntvl{60, "SessExpIntvl", "Session Expirary delay (in seconds) between non-normal disconnect and broker invalidating session and publishing LWT"};
14 config_bool retain{true, "Retain", "Whether the broker will retain LWT to publish to future subscribers."};
15 config_string connMessage{"", "Connect", "LWT Message to publish on Connect"};
16 config_string normalDisconMessage{"", "NormalDisconnect", "Message to publish on normal disconnect"};
17 ConfigEndMarker;
18
19 config_MqttLWT(config_obj &owner, const char* name, const char *desc = NULL)
20 : config_obj(owner, name, desc)
21 {
22 }
23 config_MqttLWT(const char* name, const char *desc = NULL)
24 : config_obj(name, desc)
25 {
26 }
27
28 bool valid();
29};
30
31class config_x509Cert : public config_obj
32{
33public:
34 config_fs_bulkstore cert{"/sys/mqtt/cert_", false, "ClientCert", "Certificate content"};
35 config_fs_bulkstore privKey{"/sys/mqtt/key_", false, "PrivateKey", "Private Key associated with cert"};
36 ConfigEndMarker;
37
38 config_x509Cert(config_obj &owner, const char* name, const char *desc = NULL)
39 : config_obj(owner, name, desc)
40 {
41 privKey.SetBulkstoreFlags(config_fs_bulkstore::FLAG_IS_SENSITIVE_HIDE_VALUE);
42 }
43 config_x509Cert(const char* name, const char *desc = NULL)
44 : config_obj(name, desc)
45 {
46 privKey.SetBulkstoreFlags(config_fs_bulkstore::FLAG_IS_SENSITIVE_HIDE_VALUE);
47 }
48};
49
50class config_MqttClient : public config_obj
51{
52 static int numConfigs;
53 protected:
54 static const char *createName();
55 public:
56 config_string brokerFqdn{"", "Hostname", ""};
57 config_uint brokerPort{MQTT_DEFAULT_PORT, "Port", ""};
58#if NB_SSL_SUPPORTED
59 config_bool useTLS{false, "TLS_Enabled", "Encrypt Connection using TLS"};
60#endif
61 config_string cfgClientId{"", "ClientId", ""};
62 config_string cfgUsername{"", "Username", ""};
63 config_pass cfgPassword{"", "Password", ""};
64 config_bool alwaysClean{true, "AlwayCleanStart", "Always start session with a clean slate of subscriptions."};
65 config_bool enableLWT{true, "LWT_Enabled", "Enable client use of LWT message"};
66 config_uint maxKeepAlive{MQTT_DEFAULT_KEEP_ALIVE, "KeepAlive", "The number of seconds when, after multiple failed MQTT keepalive messages, the connection will be automatically restarted (Note: the server may impose a different maximum keepalive)"};
67#if NB_SSL_SUPPORTED
68 config_x509Cert clientCert{*this, "ClientCert", "Client Cert to use to authenticate to the server"};
69#endif
70 int configNum;
71 ConfigEndMarker;
72
73 NBString interpBroker;
74
75 config_MqttClient(config_obj &owner, const char* name, const char *desc = NULL)
76 : config_obj(owner, name, desc)
77 {
78 }
79 config_MqttClient(const char* name, const char *desc = NULL)
80 : config_obj(name, desc)
81 {
82 }
83};
84
85
86#endif /* ----- #ifndef __CONFIG_MQTT_OBJ_H ----- */
Lightweight alternative to C++ CString class.
Definition nbstring.h:118
Boolean Configuration Variable.
Definition config_obj.h:997
Base class used to create configuration objects.
Definition config_obj.h:320
Password string Configuration Variable.
Definition config_obj.h:1343
String Configuration Variable.
Definition config_obj.h:1127
Unsigned 32-bit Integer Configuration Variable.
Definition config_obj.h:552
Configuration object header file.
#define MQTT_DEFAULT_KEEP_ALIVE
Definition mqtt.h:61
NetBurner String Class.