Skip to content

Commit c63d3e2

Browse files
committed
winc1500: split mqtt and http client instances
1 parent 6060ba5 commit c63d3e2

File tree

2 files changed

+16
-9
lines changed

2 files changed

+16
-9
lines changed

AdafruitIO_WINC1500.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -18,26 +18,32 @@ AdafruitIO_WINC1500::AdafruitIO_WINC1500(const char *user, const char *key, cons
1818
{
1919
_ssid = ssid;
2020
_pass = pass;
21-
_client = new WiFiSSLClient;
22-
_mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
23-
_http = new HttpClient(*_client, _host, _http_port);
21+
_mqtt_client = new WiFiSSLClient;
22+
_mqtt = new Adafruit_MQTT_Client(_mqtt_client, _host, _mqtt_port);
23+
_http_client = new WiFiSSLClient;
24+
_http = new HttpClient(*_http_client, _host, _http_port);
2425
}
2526

2627
AdafruitIO_WINC1500::AdafruitIO_WINC1500(const __FlashStringHelper *user, const __FlashStringHelper *key, const __FlashStringHelper *ssid, const __FlashStringHelper *pass):AdafruitIO(user, key)
2728
{
2829
_ssid = (const char*)ssid;
2930
_pass = (const char*)pass;
30-
_client = new WiFiSSLClient;
31-
_mqtt = new Adafruit_MQTT_Client(_client, _host, _mqtt_port);
32-
_http = new HttpClient(*_client, _host, _http_port);
31+
_mqtt_client = new WiFiSSLClient;
32+
_mqtt = new Adafruit_MQTT_Client(_mqtt_client, _host, _mqtt_port);
33+
_http_client = new WiFiSSLClient;
34+
_http = new HttpClient(*_http_client, _host, _http_port);
3335
}
3436

3537
AdafruitIO_WINC1500::~AdafruitIO_WINC1500()
3638
{
37-
if(_client)
38-
delete _client;
39+
if(_mqtt_client)
40+
delete _http_client;
41+
if(_http_client)
42+
delete _mqtt_client;
3943
if(_mqtt)
4044
delete _mqtt;
45+
if(_http)
46+
delete _http;
4147
}
4248

4349
void AdafruitIO_WINC1500::_connect()

AdafruitIO_WINC1500.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,7 +41,8 @@ class AdafruitIO_WINC1500 : public AdafruitIO {
4141
const char *_ssid;
4242
const char *_pass;
4343

44-
WiFiSSLClient *_client;
44+
WiFiSSLClient *_http_client;
45+
WiFiSSLClient *_mqtt_client;
4546

4647
};
4748

0 commit comments

Comments
 (0)