Skip to content

Commit

Permalink
fix: compatibility with Arduino core 3.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
Laxilef committed Oct 24, 2024
1 parent 0a07062 commit 14cec23
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/MqttClient.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -657,6 +657,20 @@ int MqttClient::connect(const char *host, uint16_t port)
return connect((uint32_t)0, host, port);
}

#ifdef ARDUINO_ARCH_ESP32
int MqttClient::connect(IPAddress ip, uint16_t port, int32_t timeout)
{
setConnectionTimeout(timeout);
return connect(ip, port);
}

int MqttClient::connect(const char *host, uint16_t port, int32_t timeout)
{
setConnectionTimeout(timeout);
return connect(host, port);
}
#endif

size_t MqttClient::write(uint8_t b)
{
return write(&b, sizeof(b));
Expand Down
4 changes: 4 additions & 0 deletions src/MqttClient.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,10 @@ class MqttClient : public Client {
virtual int connect(const char *host, uint16_t port = 1883);
#ifdef ESP8266
virtual int connect(const IPAddress& ip, uint16_t port) { return 0; }; /* ESP8266 core defines this pure virtual in Client.h */
#endif
#ifdef ARDUINO_ARCH_ESP32
virtual int connect(IPAddress ip, uint16_t port, int32_t timeout);
virtual int connect(const char *host, uint16_t port, int32_t timeout);
#endif
virtual size_t write(uint8_t);
virtual size_t write(const uint8_t *buf, size_t size);
Expand Down

0 comments on commit 14cec23

Please sign in to comment.