restore encrypted mqtt functionality

This commit is contained in:
technyon
2023-01-28 10:23:26 +01:00
parent e439d67276
commit d96f22f7a3
5 changed files with 30 additions and 31 deletions

View File

@@ -13,61 +13,61 @@ the LICENSE file.
namespace espMqttClientInternals {
ClientSecureSync::ClientSecureSync()
: client() {
ClientSecureSync::ClientSecureSync(WiFiClientSecure* wiFiClient)
: client(wiFiClient) {
// empty
}
bool ClientSecureSync::connect(IPAddress ip, uint16_t port) {
bool ret = client.connect(ip, port); // implicit conversion of return code int --> bool
bool ret = client->connect(ip, port); // implicit conversion of return code int --> bool
if (ret) {
#if defined(ARDUINO_ARCH_ESP8266)
client.setNoDelay(true);
client->setNoDelay(true);
#elif defined(ARDUINO_ARCH_ESP32)
// Set TCP option directly to bypass lack of working setNoDelay for WiFiClientSecure
int val = true;
client.setSocketOption(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(int));
client->setSocketOption(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(int));
#endif
}
return ret;
}
bool ClientSecureSync::connect(const char* host, uint16_t port) {
bool ret = client.connect(host, port); // implicit conversion of return code int --> bool
bool ret = client->connect(host, port); // implicit conversion of return code int --> bool
if (ret) {
#if defined(ARDUINO_ARCH_ESP8266)
client.setNoDelay(true);
client->setNoDelay(true);
#elif defined(ARDUINO_ARCH_ESP32)
// Set TCP option directly to bypass lack of working setNoDelay for WiFiClientSecure
int val = true;
client.setSocketOption(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(int));
client->setSocketOption(IPPROTO_TCP, TCP_NODELAY, &val, sizeof(int));
#endif
}
return ret;
}
size_t ClientSecureSync::write(const uint8_t* buf, size_t size) {
return client.write(buf, size);
return client->write(buf, size);
}
int ClientSecureSync::available() {
return client.available();
return client->available();
}
int ClientSecureSync::read(uint8_t* buf, size_t size) {
return client.read(buf, size);
return client->read(buf, size);
}
void ClientSecureSync::stop() {
client.stop();
client->stop();
}
bool ClientSecureSync::connected() {
return client.connected();
return client->connected();
}
bool ClientSecureSync::disconnected() {
return !client.connected();
return !client->connected();
}
} // namespace espMqttClientInternals