@@ -32,15 +32,15 @@ using namespace std::placeholders;
32
32
33
33
namespace ksf ::comps
34
34
{
35
+ ksMqttConnector::~ksMqttConnector () = default ;
36
+
35
37
ksMqttConnector::ksMqttConnector (bool sendConnectionStatus, bool usePersistentSession)
36
38
: reconnectTimer(KSF_MQTT_RECONNECT_DELAY_MS)
37
39
{
38
40
bitflags.sendConnectionStatus = sendConnectionStatus;
39
41
bitflags.usePersistentSession = usePersistentSession;
40
42
}
41
43
42
- ksMqttConnector::~ksMqttConnector () = default ;
43
-
44
44
bool ksMqttConnector::init (ksApplication* app)
45
45
{
46
46
ksMqttConfigProvider cfgProvider;
@@ -67,10 +67,9 @@ namespace ksf::comps
67
67
68
68
void ksMqttConnector::setupConnection (const std::string broker, const std::string& port, std::string login, std::string password, std::string prefix, const std::string& fingerprint)
69
69
{
70
- /* Set up secure connection if a fingerprint is provided. */
71
70
if (!fingerprint.empty ())
72
71
{
73
- auto secureClient = std::make_unique<ksMqttConnectorNetClientSecure_t>();
72
+ auto secureClient{ std::make_unique<ksMqttConnectorNetClientSecure_t>()} ;
74
73
certFingerprint = std::make_unique<misc::ksCertFingerprintHolder>();
75
74
if (certFingerprint->setup (secureClient.get (), fingerprint))
76
75
netClientUq = std::move (secureClient);
@@ -80,7 +79,7 @@ namespace ksf::comps
80
79
/* Whoops, it looks like fingerprint validation failed. */
81
80
if (!netClientUq)
82
81
return ;
83
-
82
+
84
83
/* Set socket timeouts. */
85
84
netClientUq->setTimeout (KSF_MQTT_TIMEOUT_MS);
86
85
@@ -92,7 +91,7 @@ namespace ksf::comps
92
91
ksf::from_chars (port, portNumber);
93
92
94
93
/* Create MQTT client. */
95
- mqttClientUq = std::make_unique<PubSubClient>(*netClientUq);
94
+ mqttClientUq = std::make_unique<PubSubClient>(*netClientUq. get () );
96
95
}
97
96
98
97
void ksMqttConnector::mqttConnectedInternal ()
@@ -104,8 +103,8 @@ namespace ksf::comps
104
103
105
104
void ksMqttConnector::mqttMessageInternal (const char * topic, const uint8_t * payload, uint32_t length)
106
105
{
107
- auto handlesDeviceMessage{onDeviceMessage->isBound ()};
108
- auto handlesAnyMessage{onAnyMessage->isBound ()};
106
+ bool handlesDeviceMessage{onDeviceMessage->isBound ()};
107
+ bool handlesAnyMessage{onAnyMessage->isBound ()};
109
108
110
109
if (!handlesDeviceMessage && !handlesAnyMessage)
111
110
return ;
@@ -134,7 +133,8 @@ namespace ksf::comps
134
133
135
134
void ksMqttConnector::subscribe (const std::string& topic, bool skipDevicePrefix, ksMqttConnector::QosLevel qos)
136
135
{
137
- mqttClientUq->subscribe (skipDevicePrefix ? topic.c_str () : std::string (prefix + topic).c_str (), static_cast <uint8_t >(qos));
136
+ uint8_t qosLevel{static_cast <uint8_t >(qos)};
137
+ mqttClientUq->subscribe (skipDevicePrefix ? topic.c_str () : std::string (prefix + topic).c_str (), qosLevel);
138
138
}
139
139
140
140
void ksMqttConnector::unsubscribe (const std::string& topic, bool skipDevicePrefix)
0 commit comments