diff --git a/MicroGear.cpp b/MicroGear.cpp index ef4d98f..10dba30 100644 --- a/MicroGear.cpp +++ b/MicroGear.cpp @@ -666,34 +666,6 @@ bool MicroGear::publish(char* topic, String message, bool retained) { return publish(topic, buff, retained); } -bool MicroGear::publish(char* topic, String message, String apikey) { - char buff[MAXBUFFSIZE]; - message.toCharArray(buff,MAXBUFFSIZE-1); - - char top[MAXTOPICSIZE] = ""; - strcat(top,topic); - if(apikey!=""){ - strcat(top,"/"); - char buffapikey[MAXBUFFSIZE]; - apikey.toCharArray(buffapikey,MAXBUFFSIZE); - strcat(top,buffapikey); - } - return publish(top, buff); -} - -bool MicroGear::publish(char* topic, String message, char* apikey) { - char buff[MAXBUFFSIZE]; - message.toCharArray(buff,MAXBUFFSIZE-1); - - char top[MAXTOPICSIZE] = ""; - strcat(top,topic); - if(apikey!=""){ - strcat(top,"/"); - strcat(top,apikey); - } - return publish(top, buff); -} - bool MicroGear::writeFeed(char* feedname, char *data, char* apikey) { char buff[MAXBUFFSIZE] = "/@writefeed/"; @@ -712,7 +684,6 @@ bool MicroGear::writeFeed(char* feedname, char *data) { bool MicroGear::writeFeed(char* feedname, String data, char* apikey) { char buff[MAXBUFFSIZE]; data.toCharArray(buff,MAXBUFFSIZE-1); - return writeFeed(feedname, buff, apikey); } @@ -720,6 +691,28 @@ bool MicroGear::writeFeed(char* feedname, String data) { return writeFeed(feedname, data, NULL); } +bool MicroGear::pushOwner(char *message) { + char buff[MAXBUFFSIZE] = "/@push/owner"; + return publish(buff, message); +} + +bool MicroGear::pushOwner(double message) { + char buff[MAXBUFFSIZE] = "/@push/owner"; + return publish(buff, message); +} + +bool MicroGear::pushOwner(int message) { + char buff[MAXBUFFSIZE] = "/@push/owner"; + return publish(buff, message); +} + +bool MicroGear::pushOwner(String message) { + char top[MAXBUFFSIZE] = "/@push/owner"; + char buff[MAXBUFFSIZE]; + message.toCharArray(buff,MAXBUFFSIZE-1); + return publish(top, message); +} + /* setName() is deprecated */ diff --git a/MicroGear.h b/MicroGear.h index 366adb3..166cc60 100644 --- a/MicroGear.h +++ b/MicroGear.h @@ -130,6 +130,11 @@ class MicroGear { bool writeFeed(char*, String); bool writeFeed(char*, String, char*); + bool pushOwner(char*); + bool pushOwner(double); + bool pushOwner(int); + bool pushOwner(String); + bool chat(char*, char*); bool chat(char*, int); bool chat(char*, double); diff --git a/README.md b/README.md index e04c6cf..be93e11 100644 --- a/README.md +++ b/README.md @@ -286,6 +286,20 @@ To send a revoke token control message to NETPIE and delete the token from cache --- +**void microgear.pushOwner (char *message)**
+**void microgear.pushOwner (double *message)**
+**void microgear.pushOwner (int *message)**
+**void microgear.pushOwner (String *message)**
+push notification to NETPIE mobile application + +**arguments** +* *message* - message to be sent + +```js +microgear.pushOwner("temp:25.7"); +``` +--- + **void MicroGear::loop()** This method has to be called regularly in the arduino loop() function to keep connection alive and to handle incoming messages. diff --git a/README.th.md b/README.th.md index fc1e77f..a570034 100644 --- a/README.th.md +++ b/README.th.md @@ -269,7 +269,19 @@ microgear.writeFeed("homesensor","{temp:25.7,humid:62.8,light:8.5}"); ส่งคำสั่ง revoke token ไปยัง netpie และลบ token ออกจาก cache ส่งผลให้ microgear ต้องขอ token ใหม่ในการเชื่อมต่อครั้งต่อไป --- +**void microgear.pushOwner (char *message)**
+**void microgear.pushOwner (double *message)**
+**void microgear.pushOwner (int *message)**
+**void microgear.pushOwner (String *message)**
+ส่งการแจ้งเตือน ไปยัง NETPIE mobile application +**arguments** +* *message* - ข้อความ + +```js +microgear.pushOwner("temp:25.7"); +``` +--- **void MicroGear::loop()** method นี้ควรถูกเรียกใน arduino loop() เป็นระยะๆ เพื่อที่ microgear library จะได้ keep alive connection alive และจัดการกับ message ที่เข้ามา