Junichi Katsu / Milkcocoa-os

Dependents:   mbed-os-example-wifi-milkcocoa MilkcocoaOsSample_Eth MilkcocoaOsSample_ESP8266 MilkcocoaOsSample_Eth_DigitalIn

Revision:
3:cddf81a87de3
Parent:
1:8e4149b53a8a
Child:
4:9cfd43d8de16
--- a/Milkcocoa.cpp	Wed Feb 15 02:15:55 2017 +0000
+++ b/Milkcocoa.cpp	Thu May 18 14:47:30 2017 +0000
@@ -165,6 +165,25 @@
 	return true;
 }
 
+bool Milkcocoa::push(const char *path, char *data) {
+	milkcocoa_message_t *message = message_box.alloc();
+	char *buf;
+	
+	if(message == NULL)	return false;
+
+	sprintf(message->topic, "%s/%s/push", app_id, path);
+	
+	strcpy(message->message , "{\"params\":{");
+	strcat(message->message , data);
+	strcat(message->message , "}");
+	
+	osStatus stat = message_box.put(message);
+	
+	if( stat != osOK ) return false;
+
+	return true;
+}
+
 bool Milkcocoa::send(const char *path, DataElement dataelement) {
 	milkcocoa_message_t *message = message_box.alloc();
 	char *buf;
@@ -182,6 +201,25 @@
 	return true;
 }
 
+bool Milkcocoa::send(const char *path, char *data) {
+	milkcocoa_message_t *message = message_box.alloc();
+	char *buf;
+	
+	if(message == NULL)	return false;
+
+	sprintf(message->topic, "%s/%s/send", app_id, path);
+	
+	strcpy(message->message , "{\"params\":{");
+	strcat(message->message , data);
+	strcat(message->message , "}");
+	
+	osStatus stat = message_box.put(message);
+	
+	if( stat != osOK ) return false;
+	
+	return true;
+}
+
 void Milkcocoa::loop() {
 	connect();
 	client->yield(RECV_TIMEOUT);