Skip to content

Commit 15b802f

Browse files
committed
handle null function pointer
1 parent 1ecd298 commit 15b802f

File tree

1 file changed

+6
-3
lines changed

1 file changed

+6
-3
lines changed

MicroGear.cpp

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ void msgCallback(char* topic, uint8_t* payload, unsigned int length) {
1818
}
1919
}
2020
else if (strcmp(rtopic,"&absent") == 0) {
21-
if (cb_present) {
21+
if (cb_absent) {
2222
cb_absent("absent",payload,length);
2323
}
2424
}
@@ -90,6 +90,9 @@ MicroGear::MicroGear(Client& netclient ) {
9090

9191
this->eepromoffset = 0;
9292
cb_message = NULL;
93+
cb_connected = NULL;
94+
cb_absent = NULL;
95+
cb_present = NULL;
9396
eepromready = false;
9497
}
9598

@@ -383,8 +386,8 @@ boolean MicroGear::connect(char* appid) {
383386
sprintf(buff,"/&id/%s/#",token);
384387
subscribe(buff);
385388

386-
cb_connected(NULL,NULL,0);
387-
389+
if (cb_connected)
390+
cb_connected(NULL,NULL,0);
388391

389392
break;
390393
case CLIENT_NOTCONNECT :

0 commit comments

Comments
 (0)