Skip to content

Commit 481cf14

Browse files
committed
add destructor to esp class
1 parent b8f4fe0 commit 481cf14

File tree

3 files changed

+11
-1
lines changed

3 files changed

+11
-1
lines changed

AdafruitIO.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ class AdafruitIO {
2121

2222
public:
2323
AdafruitIO();
24-
~AdafruitIO();
24+
virtual ~AdafruitIO();
2525

2626
void connect(const char *user, const char *key);
2727
void connect(const __FlashStringHelper *user, const __FlashStringHelper *key);

AdafruitIO_ESP8266.cpp

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,14 @@ AdafruitIO_ESP8266::AdafruitIO_ESP8266(const __FlashStringHelper *ssid, const __
1818
_mqtt = new Adafruit_MQTT_Client(_client, _host, _port);
1919
}
2020

21+
AdafruitIO_ESP8266::~AdafruitIO_ESP8266()
22+
{
23+
if(_client)
24+
delete _client;
25+
if(_mqtt)
26+
delete _mqtt;
27+
}
28+
2129
void AdafruitIO_ESP8266::_connect()
2230
{
2331

AdafruitIO_ESP8266.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,8 @@ class AdafruitIO_ESP8266 : public AdafruitIO {
1515
public:
1616
AdafruitIO_ESP8266(const char *ssid, const char *pass);
1717
AdafruitIO_ESP8266(const __FlashStringHelper *ssid, const __FlashStringHelper *pass);
18+
~AdafruitIO_ESP8266();
19+
1820
aio_status_t networkStatus();
1921

2022
protected:

0 commit comments

Comments
 (0)