Skip to content

Commit ae5e588

Browse files
committed
Fix bear ssl fwd def
1 parent 1b1060b commit ae5e588

File tree

3 files changed

+23
-16
lines changed

3 files changed

+23
-16
lines changed

src/ksf/comp/ksMqttConnector.cpp

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -32,15 +32,15 @@ using namespace std::placeholders;
3232

3333
namespace ksf::comps
3434
{
35+
ksMqttConnector::~ksMqttConnector() = default;
36+
3537
ksMqttConnector::ksMqttConnector(bool sendConnectionStatus, bool usePersistentSession)
3638
: reconnectTimer(KSF_MQTT_RECONNECT_DELAY_MS)
3739
{
3840
bitflags.sendConnectionStatus = sendConnectionStatus;
3941
bitflags.usePersistentSession = usePersistentSession;
4042
}
4143

42-
ksMqttConnector::~ksMqttConnector() = default;
43-
4444
bool ksMqttConnector::init(ksApplication* app)
4545
{
4646
ksMqttConfigProvider cfgProvider;
@@ -67,10 +67,9 @@ namespace ksf::comps
6767

6868
void ksMqttConnector::setupConnection(const std::string broker, const std::string& port, std::string login, std::string password, std::string prefix, const std::string& fingerprint)
6969
{
70-
/* Set up secure connection if a fingerprint is provided. */
7170
if (!fingerprint.empty())
7271
{
73-
auto secureClient = std::make_unique<ksMqttConnectorNetClientSecure_t>();
72+
auto secureClient{std::make_unique<ksMqttConnectorNetClientSecure_t>()};
7473
certFingerprint = std::make_unique<misc::ksCertFingerprintHolder>();
7574
if (certFingerprint->setup(secureClient.get(), fingerprint))
7675
netClientUq = std::move(secureClient);
@@ -80,7 +79,7 @@ namespace ksf::comps
8079
/* Whoops, it looks like fingerprint validation failed. */
8180
if (!netClientUq)
8281
return;
83-
82+
8483
/* Set socket timeouts. */
8584
netClientUq->setTimeout(KSF_MQTT_TIMEOUT_MS);
8685

@@ -92,7 +91,7 @@ namespace ksf::comps
9291
ksf::from_chars(port, portNumber);
9392

9493
/* Create MQTT client. */
95-
mqttClientUq = std::make_unique<PubSubClient>(*netClientUq);
94+
mqttClientUq = std::make_unique<PubSubClient>(*netClientUq.get());
9695
}
9796

9897
void ksMqttConnector::mqttConnectedInternal()
@@ -104,8 +103,8 @@ namespace ksf::comps
104103

105104
void ksMqttConnector::mqttMessageInternal(const char* topic, const uint8_t* payload, uint32_t length)
106105
{
107-
auto handlesDeviceMessage{onDeviceMessage->isBound()};
108-
auto handlesAnyMessage{onAnyMessage->isBound()};
106+
bool handlesDeviceMessage{onDeviceMessage->isBound()};
107+
bool handlesAnyMessage{onAnyMessage->isBound()};
109108

110109
if (!handlesDeviceMessage && !handlesAnyMessage)
111110
return;
@@ -134,7 +133,8 @@ namespace ksf::comps
134133

135134
void ksMqttConnector::subscribe(const std::string& topic, bool skipDevicePrefix, ksMqttConnector::QosLevel qos)
136135
{
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);
138138
}
139139

140140
void ksMqttConnector::unsubscribe(const std::string& topic, bool skipDevicePrefix)

src/ksf/comp/ksMqttConnector.h

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@
2020
#if (defined(ESP32) && ESP_ARDUINO_VERSION_MAJOR >= 3)
2121
#define ksMqttConnectorNetClient_t NetworkClient
2222
#define ksMqttConnectorNetClientSecure_t NetworkClientSecure
23-
#else
23+
#elif defined (ESP8266)
2424
#define ksMqttConnectorNetClient_t WiFiClient
25-
#define ksMqttConnectorNetClientSecure_t WiFiClientSecure
25+
#define ksMqttConnectorNetClientSecure_t BearSSL::WiFiClientSecure
26+
#else
27+
#error Platform not implemented.
2628
#endif
2729

2830
class PubSubClient;

src/ksf/misc/ksCertUtils.h

Lines changed: 10 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,14 +12,19 @@
1212
#include <string>
1313
#include <stdint.h>
1414

15-
#if (defined(ESP32) && ESP_ARDUINO_VERSION_MAJOR >= 3)
16-
#define ksCertUtilsNetCLientSecure_t NetworkClientSecure
17-
#else
15+
#if defined(ESP32)
1816
#define ksCertUtilsNetCLientSecure_t WiFiClientSecure
17+
class ksCertUtilsNetCLientSecure_t
18+
#elif defined(ESP8266)
19+
namespace BearSSL
20+
{
21+
class WiFiClientSecure;
22+
}
23+
#define ksCertUtilsNetCLientSecure_t BearSSL::WiFiClientSecure
24+
#else
25+
#error Platform not implemented.
1926
#endif
2027

21-
class ksCertUtilsNetCLientSecure_t;
22-
2328
namespace ksf::misc
2429
{
2530
/*!

0 commit comments

Comments
 (0)