Skip to content

Commit 1fda3cb

Browse files
committed
support new event api
1 parent 325a26f commit 1fda3cb

File tree

1 file changed

+10
-7
lines changed

1 file changed

+10
-7
lines changed

MicroGear.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,13 +10,13 @@ void msgCallback(char* topic, uint8_t* payload, unsigned int length) {
1010
char* rtopic = topic+topicprefixlen+1;
1111

1212
/* if a control message */
13-
if (*rtopic == '@') {
14-
if (strcmp(rtopic,"@present") == 0) {
13+
if (*rtopic == '&') {
14+
if (strcmp(rtopic,"&present") == 0) {
1515
if (cb_present) {
1616
cb_present("present",payload,length);
1717
}
1818
}
19-
else if (strcmp(rtopic,"@absent") == 0) {
19+
else if (strcmp(rtopic,"&absent") == 0) {
2020
if (cb_present) {
2121
cb_absent("absent",payload,length);
2222
}
@@ -100,12 +100,12 @@ void MicroGear::on(unsigned char event, void (* callback)(char*, uint8_t*,unsign
100100
case PRESENT :
101101
if (callback) cb_present = callback;
102102
if (connected())
103-
subscribe("/@present");
103+
subscribe("/&present");
104104
break;
105105
case ABSENT :
106106
if (callback) cb_absent = callback;
107107
if (connected())
108-
subscribe("/@absent");
108+
subscribe("/&absent");
109109
break;
110110
}
111111
}
@@ -348,9 +348,12 @@ boolean MicroGear::connect(char* appid) {
348348
case CLIENT_CONNECTED :
349349
backoff = MINBACKOFFTIME;
350350
if (cb_present)
351-
subscribe("/@present");
351+
subscribe("/&present");
352352
if (cb_absent)
353-
subscribe("/@absent");
353+
subscribe("/&absent");
354+
355+
sprintf(buff,"/&id/%s/#",token);
356+
subscribe(buff);
354357

355358
break;
356359
case CLIENT_NOTCONNECT :

0 commit comments

Comments
 (0)