Skip to content

Commit 332d0a6

Browse files
committed
- added initialiser to connection(NULL) in constructor
- update() checks against connection not being NULL
1 parent f0e4ed3 commit 332d0a6

File tree

1 file changed

+10
-6
lines changed

1 file changed

+10
-6
lines changed

src/ArduinoIoTCloud.cpp

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,8 @@ static unsigned long getTime() {
1818
ArduinoIoTCloudClass::ArduinoIoTCloudClass() :
1919
_thing_id (""),
2020
_bearSslClient(NULL),
21-
_mqttClient (NULL)
21+
_mqttClient (NULL),
22+
connection (NULL)
2223
{
2324
}
2425

@@ -265,12 +266,15 @@ void ArduinoIoTCloudClass::handleMessage(int length)
265266
}
266267

267268
void ArduinoIoTCloudClass::connectionCheck() {
268-
connection->check();
269-
if (connection->getStatus() != CONNECTION_STATE_CONNECTED) {
270-
if(iotStatus == IOT_STATUS_CLOUD_CONNECTED)
271-
iotStatus = IOT_STATUS_CLOUD_DISCONNECTED;
272-
return;
269+
if(connection != NULL){
270+
connection->check();
271+
if (connection->getStatus() != CONNECTION_STATE_CONNECTED) {
272+
if(iotStatus == IOT_STATUS_CLOUD_CONNECTED)
273+
iotStatus = IOT_STATUS_CLOUD_DISCONNECTED;
274+
return;
275+
}
273276
}
277+
274278
char msgBuffer[120];
275279
int arduinoIoTConnectionAttempt;
276280

0 commit comments

Comments
 (0)