diff --git a/component.mk b/component.mk new file mode 100755 index 0000000..b530e56 --- /dev/null +++ b/component.mk @@ -0,0 +1,5 @@ + +COMPONENT_ADD_INCLUDEDIRS := src/ +COMPONENT_SRCDIRS := src/ +COMPONENT_SRCDIRS += src/AsyncMqttClient +COMPONENT_SRCDIRS += src/AsyncMqttClient/Packets diff --git a/src/AsyncMqttClient.cpp b/src/AsyncMqttClient.cpp index 8fa959d..86041d8 100644 --- a/src/AsyncMqttClient.cpp +++ b/src/AsyncMqttClient.cpp @@ -24,7 +24,13 @@ AsyncMqttClient::AsyncMqttClient() , _willPayloadLength(0) , _willQos(0) , _willRetain(false) -, _parsingInformation { .bufferState = AsyncMqttClientInternals::BufferState::NONE } +, _parsingInformation { .bufferState = AsyncMqttClientInternals::BufferState::NONE, + .maxTopicLength = 0, + .topicBuffer = NULL, + .packetType = 0, + .packetFlags = 0, + .remainingLength = 0 + } , _currentParsedPacket(nullptr) , _remainingLengthBufferPosition(0) , _nextPacketId(1) { @@ -118,7 +124,14 @@ AsyncMqttClient& AsyncMqttClient::addServerFingerprint(const uint8_t* fingerprin _secureServerFingerprints.push_back(newFingerprint); return *this; } +#ifdef ESP32 +AsyncMqttClient& AsyncMqttClient::setRootCa(const char* rootca, const size_t len) { + _client.setRootCa(rootca, len); + return *this; +} #endif +#endif + AsyncMqttClient& AsyncMqttClient::onConnect(AsyncMqttClientInternals::OnConnectUserCallback callback) { _onConnectUserCallbacks.push_back(callback); @@ -178,6 +191,7 @@ void AsyncMqttClient::_onConnect(AsyncClient* client) { (void)client; #if ASYNC_TCP_SSL_ENABLED +#ifndef ESP32 if (_secure && _secureServerFingerprints.size() > 0) { SSL* clientSsl = _client.getSSL(); @@ -195,6 +209,7 @@ void AsyncMqttClient::_onConnect(AsyncClient* client) { return; } } +#endif #endif char fixedHeader[5]; diff --git a/src/AsyncMqttClient.hpp b/src/AsyncMqttClient.hpp index 4f41210..f06c7a3 100644 --- a/src/AsyncMqttClient.hpp +++ b/src/AsyncMqttClient.hpp @@ -15,7 +15,11 @@ #endif #if ASYNC_TCP_SSL_ENABLED +#ifdef ESP32 +#include +#else #include +#endif #define SHA1_SIZE 20 #endif @@ -62,6 +66,9 @@ class AsyncMqttClient { #if ASYNC_TCP_SSL_ENABLED AsyncMqttClient& setSecure(bool secure); AsyncMqttClient& addServerFingerprint(const uint8_t* fingerprint); +#ifdef ESP32 + AsyncMqttClient& setRootCa(const char* rootca, const size_t len); + #endif #endif AsyncMqttClient& onConnect(AsyncMqttClientInternals::OnConnectUserCallback callback);