Fix crash on MqttClient timeout when not linked to a broker

This commit is contained in:
hsaturn
2021-03-22 01:59:17 +01:00
parent 18b5f0c27b
commit bd2e7cc5f6
2 changed files with 9 additions and 5 deletions

View File

@@ -114,7 +114,9 @@ class MqttClient
void connect(MqttBroker* parent);
void connect(std::string broker, uint16_t port);
bool connected() { return client==nullptr || client->connected(); }
bool connected() { return
(parent!=nullptr and client==nullptr) or
(client and client->connected()); }
void write(const char* buf, size_t length)
{ if (client) client->write(buf, length); }